aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzyray <fuzzyray@gentoo.org>2010-03-12 21:44:29 +0000
committerfuzzyray <fuzzyray@gentoo.org>2010-03-12 21:44:29 +0000
commit1ddc073811b7b69aab22cd65990bbca8e7104bef (patch)
tree5ca2ef92478538f44b6abc9a96a8110b559fa867 /pym/gentoolkit/helpers.py
parentRemove stray analyse script (diff)
downloadgentoolkit-1ddc073811b7b69aab22cd65990bbca8e7104bef.tar.gz
gentoolkit-1ddc073811b7b69aab22cd65990bbca8e7104bef.tar.bz2
gentoolkit-1ddc073811b7b69aab22cd65990bbca8e7104bef.zip
Update to genscripts rev 382. This has more fixes for py3k and the modular rewrite of eclean.
svn path=/trunk/gentoolkit/; revision=755
Diffstat (limited to 'pym/gentoolkit/helpers.py')
-rw-r--r--pym/gentoolkit/helpers.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/pym/gentoolkit/helpers.py b/pym/gentoolkit/helpers.py
index 0aad2a7..6888619 100644
--- a/pym/gentoolkit/helpers.py
+++ b/pym/gentoolkit/helpers.py
@@ -27,7 +27,9 @@ __docformat__ = 'epytext'
# Imports
# =======
+import sys
import re
+import codecs
from functools import partial
from itertools import chain
@@ -195,7 +197,8 @@ class ChangeLog(object):
result = []
partial_entries = []
- with open(self.changelog_path) as log:
+ with codecs.open(self.changelog_path, encoding="utf-8",
+ errors="replace") as log:
for line in log:
if line.startswith('#'):
continue
@@ -434,16 +437,20 @@ def get_installed_cpvs(predicate=None):
def print_file(path):
"""Display the contents of a file."""
- with open(path) as open_file:
+ out = sys.stdout
+ if hasattr(out, "buffer"):
+ out = out.buffer
+
+ with open(path, "rb") as open_file:
lines = open_file.read()
- print(lines.strip())
+ print(lines.strip(), file = out)
-def print_sequence(seq):
+def print_sequence(seq, file = sys.stdout):
"""Print every item of a sequence."""
for item in seq:
- print(item)
+ print(item, file = file)
def uniqify(seq, preserve_order=True):