From e37dc80c145d36eb1c76c17bf0ae5a3927b09a64 Mon Sep 17 00:00:00 2001 From: Sebastian Luther Date: Wed, 19 May 2010 18:15:00 +0200 Subject: [PATCH] Add _emerge.Package.__str__() for nicer output formatting --- pym/_emerge/Package.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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") -- 2.26.2