From: Sebastian Luther Date: Wed, 19 May 2010 16:15:00 +0000 (+0200) Subject: Add _emerge.Package.__str__() for nicer output formatting X-Git-Tag: v2.2_rc68~594 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e37dc80c145d36eb1c76c17bf0ae5a3927b09a64;p=portage.git Add _emerge.Package.__str__() for nicer output formatting --- diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index 8e0c37890..adbd0f45e 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -137,6 +137,34 @@ class Package(Task): self.invalid[msg_type] = msgs msgs.append(msg) + def __str__(self): + if self.operation is None: + self.operation = "merge" + if self.onlydeps or self.installed: + self.operation = "nomerge" + + if self.operation == "merge": + if self.type_name == "binary": + cpv_color = "PKG_BINARY_MERGE" + else: + cpv_color = "PKG_MERGE" + else: + cpv_color = "PKG_NOMERGE" + + s = "(%s, %s" \ + % (portage.output.colorize(cpv_color, self.cpv) , self.type_name) + + if self.type_name == "installed": + if self.root != "/": + s += " in '%s'" % self.root + else: + if self.operation == "merge": + s += " scheduled for merge" + if self.root != "/": + s += " to '%s'" % self.root + s += ")" + return s + class _use_class(object): __slots__ = ("__weakref__", "enabled")