Add _emerge.Package.__str__() for nicer output formatting
authorSebastian Luther <SebastianLuther@gmx.de>
Wed, 19 May 2010 16:15:00 +0000 (18:15 +0200)
committerZac Medico <zmedico@gentoo.org>
Thu, 20 May 2010 09:50:05 +0000 (02:50 -0700)
pym/_emerge/Package.py

index 8e0c37890c514a6fdb20a0325352e648102a669e..adbd0f45e9467ba59a147efbf62819dc1b9eea33 100644 (file)
@@ -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")