aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Varner <fuzzyray@gentoo.org>2015-11-24 13:59:02 -0600
committerPaul Varner <fuzzyray@gentoo.org>2015-11-24 13:59:02 -0600
commite90e838718c737a1d41e4b8bc64e9e520d65270b (patch)
tree955be636fa2a90f35327246bc9e514591650d51e /pym/gentoolkit/helpers.py
parentChange all open() calls to use Unicode. (diff)
downloadgentoolkit-e90e838718c737a1d41e4b8bc64e9e520d65270b.tar.gz
gentoolkit-e90e838718c737a1d41e4b8bc64e9e520d65270b.tar.bz2
gentoolkit-e90e838718c737a1d41e4b8bc64e9e520d65270b.zip
Fix the file open() calls to work with Python 2
The generalized file open call needs to look like: with open(_unicode_encode(path, encoding=_encodings['fs'])) as open_file
Diffstat (limited to 'pym/gentoolkit/helpers.py')
-rw-r--r--pym/gentoolkit/helpers.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/pym/gentoolkit/helpers.py b/pym/gentoolkit/helpers.py
index f9da6cd..b7314b9 100644
--- a/pym/gentoolkit/helpers.py
+++ b/pym/gentoolkit/helpers.py
@@ -194,8 +194,8 @@ class ChangeLog(object):
result = []
partial_entries = []
- with open(_unicode_encode(self.changelog_path),
- encoding=_encodings['fs'], errors="replace") as log:
+ with open(_unicode_encode(self.changelog_path,
+ encoding=_encodings['fs'], errors="replace")) as log:
for line in log:
if line.startswith('#'):
continue
@@ -464,7 +464,7 @@ def get_bintree_cpvs(predicate=None):
def print_file(path):
"""Display the contents of a file."""
- with open(_unicode_encode(path), encoding=_encodings['fs'], mode="rb") as open_file:
+ with open(_unicode_encode(path, encoding=_encodings['fs']), mode="rb") as open_file:
lines = open_file.read()
pp.uprint(lines.strip())