From a15f54d284e3913b1993a4d9dd2b4db7c46713b5 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sun, 30 Jan 2011 00:57:46 -0800 Subject: [PATCH] Use the new _getRawMissingKeyword() which optimizes the keyword display. Misc. whitespace cleanup --- pym/_emerge/Package.py | 26 +++++------ pym/_emerge/resolver/output.py | 80 ++++++++++++++++------------------ 2 files changed, 51 insertions(+), 55 deletions(-) diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index ae9e8f293..c501b1ac8 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -240,23 +240,23 @@ class Package(Task): def accepted_keyword(self): """returns the keyword used from the ebuild's KEYWORDS string""" - keywords = set(self.metadata.get('KEYWORDS').split()) - accept_keywords = set(self.root_config.settings['ACCEPT_KEYWORDS'].split()) - used_keyword = list(set.intersection(keywords, accept_keywords)) - if used_keyword and len(used_keyword) == 1: - used_keyword = used_keyword[0] - elif len(used_keyword) > 1: - # you can raise an error here if you prefer, remove it, or set the correct levels - writemsg_level( "_emerge.output.resolver.Display(), too many keywords recieved for pkg: %s, %s" - % (pkg.cpv, used_keyword)) - used_keyword = used_keyword[0] - return used_keyword + missing, _keywords = \ + self.root_config.settings._getRawMissingKeywords( + self.cpv, self.metadata) + if '**' in missing: + return '**' + if missing: # keywords to evaluate + for keyword in _keywords: + used_keyword = '~' + keyword + if used_keyword in missing: + return used_keyword + return '' def isHardMasked(self): """returns a bool if the cpv is in the list of expanded pmaskdict[cp] availble ebuilds""" - pmask = self.root_config.settings._getRawMaskAtom(self.cpv, self.metadata) - print "pmask =", pmask + pmask = self.root_config.settings._getRawMaskAtom( + self.cpv, self.metadata) return pmask is not None diff --git a/pym/_emerge/resolver/output.py b/pym/_emerge/resolver/output.py index f1af30b25..d7d18c98c 100644 --- a/pym/_emerge/resolver/output.py +++ b/pym/_emerge/resolver/output.py @@ -33,7 +33,7 @@ if sys.hexversion >= 0x3000000: class Display(object): """Formats and outputs the depgrah supplied it for merge/re-merge, etc. - + __call__() @param depgraph: list @param favorites: defaults to [] @@ -70,7 +70,7 @@ class Display(object): def _blockers(self, pkg, fetch_symbol): """Processes pkg for blockers and adds colorized strings to self.print_msg and self.blockers - + @param pkg: _emerge.Package instance @param fetch_symbol: string @rtype: bool @@ -86,7 +86,7 @@ class Display(object): addl = "%s %s " % (colorize(self.blocker_style, "B"), fetch_symbol) self.resolved = dep_expand( - str(pkg.atom).lstrip("!"), mydb=self.vardb, + str(pkg.atom).lstrip("!"), mydb=self.vardb, settings=self.pkgsettings ) if self.conf.columns and self.conf.quiet: @@ -94,7 +94,7 @@ class Display(object): else: addl = "[%s %s] %s%s" % \ (colorize(self.blocker_style, "blocks"), - addl, self.indent, + addl, self.indent, colorize(self.blocker_style, str(self.resolved)) ) block_parents = self.conf.blocker_parents.parent_nodes(pkg) @@ -118,14 +118,14 @@ class Display(object): def _display_use(self, pkg, myoldbest, myinslotlist): """ USE flag display - + @param pkg: _emerge.Package instance @param myoldbest: list of installed versions @param myinslotlist: list of installed slots Modifies class globals: self.forced_flags, self.cur_iuse, self.old_iuse, self.old_use, self.use_expand """ - + self.forced_flags = set() self.forced_flags.update(pkg.use.force) self.forced_flags.update(pkg.use.mask) @@ -159,32 +159,27 @@ class Display(object): def _display_keyword(self, pkg): """ keyword display - + @param pkg: _emerge.Package instance Modifies self.verboseadd """ used_keyword = pkg.accepted_keyword() hardmasked = pkg.isHardMasked() - text = '' - if '~' in used_keyword: - text = used_keyword - elif not used_keyword: - text = '**' - if text: + if used_keyword: if hardmasked: - self.verboseadd += red('%s ' % text) + self.verboseadd += 'keyword=' + red('[%s] ' % used_keyword) else: - self.verboseadd += yellow('%s ' % text) + self.verboseadd += 'keyword=' + yellow('%s ' % used_keyword) return def map_to_use_expand(self, myvals, forced_flags=False, remove_hidden=True): """Map use expand variables - + @param myvals: list @param forced_flags: bool @param remove_hidden: bool - @rtype ret dictionary + @rtype ret dictionary or ret dict, forced dict. """ ret = {} @@ -212,7 +207,7 @@ class Display(object): def recheck_hidden(self, pkg): """ Prevent USE_EXPAND_HIDDEN flags from being hidden if they are the only thing that triggered reinstallation. - + @param pkg: _emerge.Package instance Modifies self.use_expand_hidden, self.use_expand, self.verboseadd """ @@ -243,7 +238,7 @@ class Display(object): self.use_expand.sort() self.use_expand.insert(0, "USE") - + for key in self.use_expand: if key in self.use_expand_hidden: continue @@ -258,7 +253,7 @@ class Display(object): @staticmethod def pkgprint(pkg_str, pkg_info): """Colorizes a string acording to pkg_info settings - + @param pkg_str: string @param pkg_info: dictionary @rtype colorized string @@ -291,7 +286,7 @@ class Display(object): def verbose_size(self, pkg, repoadd_set, pkg_info): """Determines the size of the downloads reqired - + @param pkg: _emerge.Package instance @param repoadd_set: set of repos to add @param pkg_info: dictionary @@ -349,11 +344,11 @@ class Display(object): @staticmethod def convert_myoldbest(myoldbest): """converts and colorizes a version list to a string - + @param myoldbest: list @rtype string. """ - # Convert myoldbest from a list to a string. + # Convert myoldbest from a list to a string. myoldbest_str = "" if myoldbest: versions = [] @@ -384,7 +379,7 @@ class Display(object): def _set_non_root_columns(self, addl, pkg_info, pkg): """sets the indent level and formats the output - + @param addl: already defined string to add to @param pkg_info: dictionary @param pkg: _emerge.Package instance @@ -418,7 +413,7 @@ class Display(object): def _set_root_columns(self, addl, pkg_info, pkg): """sets the indent level and formats the output - + @param addl: already defined string to add to @param pkg_info: dictionary @param pkg: _emerge.Package instance @@ -473,7 +468,7 @@ class Display(object): def _insert_slot(self, pkg, pkg_info, myinslotlist): """Adds slot info to the message - + @returns addl: formatted slot info @returns myoldbest: installed version list Modifies self.counters.downgrades, self.counters.upgrades, @@ -500,7 +495,7 @@ class Display(object): def _new_slot(self, pkg, pkg_info): """New slot, mark it new. - + @returns addl: formatted slot info @returns myoldbest: installed version list Modifies self.counters.newslot, self.counters.binary @@ -516,7 +511,7 @@ class Display(object): def print_messages(self, show_repos): """Performs the actual output printing of the pre-formatted messages - + @param show_repos: bool. """ for msg in self.print_msg: @@ -543,7 +538,7 @@ class Display(object): def print_verbose(self, show_repos): """Prints the verbose output to std_out - + @param show_repos: bool. """ writemsg_stdout('\n%s\n' % (self.counters,), noiselevel=-1) @@ -567,11 +562,11 @@ class Display(object): def get_display_list(self, mylist): """Determines the display list to process - + @param mylist @rtype list Modifies self.counters.blocks, self.counters.blocks_satisfied, - + """ unsatisfied_blockers = [] ordered_nodes = [] @@ -596,11 +591,11 @@ class Display(object): def set_pkg_info(self, pkg, ordered): """Sets various pkg_info dictionary variables - + @param pkg: _emerge.Package instance @param ordered: bool @rtype pkg_info dictionary - Modifies self.counters.restrict_fetch, + Modifies self.counters.restrict_fetch, self.counters.restrict_fetch_satisfied """ pkg_info = PkgInfo() @@ -640,7 +635,7 @@ class Display(object): def do_changelog(self, pkg, pkg_info): """Processes and adds the changelog text to the master text for output - + @param pkg: _emerge.Package instance @param pkg_info: dictionay Modifies self.changelogs @@ -659,7 +654,7 @@ class Display(object): def check_system_world(self, pkg): """Checks for any occurances of the package in the system or world sets - + @param pkg: _emerge.Package instance @rtype system and world booleans """ @@ -684,7 +679,7 @@ class Display(object): except InvalidDependString: # This is reported elsewhere if relevant. pass - return system, world + return system, world @staticmethod @@ -706,12 +701,12 @@ class Display(object): "empty" param testing because "empty" param is used for -u, where you still *do* want to see when something is being upgraded. - + @param pkg: _emerge.Package instance @param pkg_info: dictionay @rtype addl, myoldbest: list, myinslotlist: list Modifies self.counters.reinst, self.counters.binary, self.counters.new - + """ myoldbest = [] myinslotlist = None @@ -753,14 +748,14 @@ class Display(object): def __call__(self, depgraph, mylist, favorites=None, verbosity=None): """The main operation to format and display the resolver output. - + @param depgraph: dependency grah @param mylist: list of packages being processed @param favorites: list, defaults to [] @param verbosity: verbose level, defaults to None Modifies self.conf, self.myfetchlist, self.portdb, self.vardb, - self.pkgsettings, self.verboseadd, self.oldlp, self.newlp, - self.print_msg, + self.pkgsettings, self.verboseadd, self.oldlp, self.newlp, + self.print_msg, """ if favorites is None: favorites = [] @@ -789,7 +784,8 @@ class Display(object): self._get_installed_best(pkg, pkg_info) self.verboseadd = "" self.repoadd = None - self._display_keyword(pkg) + if self.conf.verbosity == 3: + self._display_keyword(pkg) self._display_use(pkg, pkg_info.oldbest, myinslotlist) self.recheck_hidden(pkg) if self.conf.verbosity == 3: -- 2.26.2