summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-07-20 20:43:48 +0000
committerZac Medico <zmedico@gentoo.org>2009-07-20 20:43:48 +0000
commit3020eb6852f91913b13ff7ad75f64d7d8914f973 (patch)
treeb999b2f89bbf1bc5909e083b0ac7e7257f5e37ee
parentd654241befc7e1610689b13c646bad24be956403 (diff)
downloadportage-3020eb6852f91913b13ff7ad75f64d7d8914f973.tar.gz
portage-3020eb6852f91913b13ff7ad75f64d7d8914f973.tar.bz2
portage-3020eb6852f91913b13ff7ad75f64d7d8914f973.zip
Use a lazy reference to sys.stdout, in case the API consumer has
temporarily overridden stdout. svn path=/main/trunk/; revision=13840
-rw-r--r--pym/_emerge/JobStatusDisplay.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/pym/_emerge/JobStatusDisplay.py b/pym/_emerge/JobStatusDisplay.py
index 3511ccb5b..561b78c2d 100644
--- a/pym/_emerge/JobStatusDisplay.py
+++ b/pym/_emerge/JobStatusDisplay.py
@@ -44,8 +44,7 @@ class JobStatusDisplay(object):
'newline' : 'nel',
}
- def __init__(self, out=sys.stdout, quiet=False, xterm_titles=True):
- object.__setattr__(self, "out", out)
+ def __init__(self, quiet=False, xterm_titles=True):
object.__setattr__(self, "quiet", quiet)
object.__setattr__(self, "xterm_titles", xterm_titles)
object.__setattr__(self, "maxval", 0)
@@ -56,7 +55,7 @@ class JobStatusDisplay(object):
object.__setattr__(self, "width", 80)
self.reset()
- isatty = hasattr(out, "isatty") and out.isatty()
+ isatty = hasattr(self.out, "isatty") and self.out.isatty()
object.__setattr__(self, "_isatty", isatty)
if not isatty or not self._init_term():
term_codes = {}
@@ -68,6 +67,12 @@ class JobStatusDisplay(object):
if not isinstance(v, basestring):
self._term_codes[k] = v.decode(encoding, 'replace')
+ @property
+ def out(self):
+ """Use a lazy reference to sys.stdout, in case the API consumer has
+ temporarily overridden stdout."""
+ return sys.stdout
+
def _init_term(self):
"""
Initialize term control codes.