summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-09-16 04:32:31 -0700
committerZac Medico <zmedico@gentoo.org>2010-09-16 04:32:31 -0700
commitaf9eb15b72eadb8fc5e271fe2b518103b47567c9 (patch)
treee5616c2dfb187966c1db0366716e68fcf3b4bf13
parent0a00c6f1d01487299f05da6d6f5dbd9f5ff764f9 (diff)
downloadportage-af9eb15b72eadb8fc5e271fe2b518103b47567c9.tar.gz
portage-af9eb15b72eadb8fc5e271fe2b518103b47567c9.tar.bz2
portage-af9eb15b72eadb8fc5e271fe2b518103b47567c9.zip
Make Package __str__ and __unicode__ methods more like DependencyArg.
-rw-r--r--pym/_emerge/Package.py10
-rw-r--r--pym/_emerge/Scheduler.py6
2 files changed, 13 insertions, 3 deletions
diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py
index 0db16fb2f..66ac7ff67 100644
--- a/pym/_emerge/Package.py
+++ b/pym/_emerge/Package.py
@@ -4,7 +4,7 @@
import sys
from itertools import chain
import portage
-from portage import _unicode_decode
+from portage import _encodings, _unicode_decode, _unicode_encode
from portage.cache.mappings import slot_dict_class
from portage.const import EBUILD_PHASES
from portage.dep import Atom, check_required_use, use_reduce, \
@@ -298,6 +298,14 @@ class Package(Task):
s += ")"
return s
+ if sys.hexversion < 0x3000000:
+
+ __unicode__ = __str__
+
+ def __str__(self):
+ return _unicode_encode(self.__unicode__(),
+ encoding=_encodings['content'])
+
class _use_class(object):
__slots__ = ("__weakref__", "enabled")
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index d45f26d9f..4b6b80f76 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -19,7 +19,7 @@ import portage
from portage import StringIO
from portage import os
from portage import _encodings
-from portage import _unicode_encode
+from portage import _unicode_decode, _unicode_encode
from portage.cache.mappings import slot_dict_class
from portage.const import LIBC_PACKAGE_ATOM
from portage.elog.messages import eerror
@@ -1203,7 +1203,9 @@ class Scheduler(PollScheduler):
printer.eerror(line)
printer.eerror("")
for failed_pkg in self._failed_pkgs_all:
- msg = " %s" % (colorize('INFORM', failed_pkg.pkg.__str__()),)
+ # Use _unicode_decode() to force unicode format string so
+ # that Package.__unicode__() is called in python2.
+ msg = _unicode_decode(" %s") % (failed_pkg.pkg,)
log_path = self._locate_failure_log(failed_pkg)
if log_path is not None:
msg += ", Log file:"