summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-01-18 09:27:26 -0800
committerZac Medico <zmedico@gentoo.org>2013-01-18 09:27:26 -0800
commitef714a6eff72dec7f4ac2104694f29cdc695db9d (patch)
treedb07fe2b8a759a697c5579638d06dc4b02a2470d
parent417692f361be32de353bc4d698b43d7a8121ec6d (diff)
downloadportage-ef714a6eff72dec7f4ac2104694f29cdc695db9d.tar.gz
portage-ef714a6eff72dec7f4ac2104694f29cdc695db9d.tar.bz2
portage-ef714a6eff72dec7f4ac2104694f29cdc695db9d.zip
egencache: unicode_literals for TextIOWrapper
-rwxr-xr-xbin/egencache30
1 files changed, 14 insertions, 16 deletions
diff --git a/bin/egencache b/bin/egencache
index 87673a0a0..797105c43 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -2,7 +2,8 @@
# Copyright 2009-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-from __future__ import print_function
+# unicode_literals for compat with TextIOWrapper in Python 2
+from __future__ import print_function, unicode_literals
import platform
import signal
@@ -524,14 +525,14 @@ class GenUseLocalDesc(object):
encoding=_encodings['fs'], errors='strict'),
mode='a', encoding=_encodings['repo.content'],
errors='backslashreplace')
- output.write(_unicode_decode('\n'))
+ output.write('\n')
else:
- output.write(textwrap.dedent(_unicode_decode('''\
+ output.write(textwrap.dedent('''\
# This file is deprecated as per GLEP 56 in favor of metadata.xml. Please add
# your descriptions to your package's metadata.xml ONLY.
# * generated automatically using egencache *
- ''')))
+ '''))
# The cmp function no longer exists in python3, so we'll
# implement our own here under a slightly different name
@@ -616,8 +617,7 @@ class GenUseLocalDesc(object):
resatoms = sorted(reskeys, key=cmp_sort_key(atomcmp))
resdesc = resdict[reskeys[resatoms[-1]]]
- output.write(_unicode_decode(
- '%s:%s - %s\n' % (cp, flag, resdesc)))
+ output.write('%s:%s - %s\n' % (cp, flag, resdesc))
output.close()
@@ -714,12 +714,12 @@ class GenChangeLogs(object):
self.returncode |= 2
return
- output.write(textwrap.dedent(_unicode_decode('''\
+ output.write(textwrap.dedent('''\
# ChangeLog for %s
# Copyright 1999-%s Gentoo Foundation; Distributed under the GPL v2
# $Header: $
- ''' % (cp, time.strftime('%Y')))))
+ ''' % (cp, time.strftime('%Y'))))
# now grab all the commits
commits = self.grab(['git', 'rev-list', 'HEAD', '--', '.']).split()
@@ -783,11 +783,10 @@ class GenChangeLogs(object):
# Reverse the sort order for headers.
for c in reversed(changed):
if c.startswith('+') and c.endswith('.ebuild'):
- output.write(_unicode_decode(
- '*%s (%s)\n' % (c[1:-7], date)))
+ output.write('*%s (%s)\n' % (c[1:-7], date))
wroteheader = True
if wroteheader:
- output.write(_unicode_decode('\n'))
+ output.write('\n')
# strip '<cp>: ', '[<cp>] ', and similar
body[0] = re.sub(r'^\W*' + re.escape(cp) + r'\W+', '', body[0])
@@ -807,13 +806,12 @@ class GenChangeLogs(object):
# don't break filenames on hyphens
self._wrapper.break_on_hyphens = False
- output.write(_unicode_decode(
- self._wrapper.fill(
- '%s; %s %s:' % (date, author, ', '.join(changed)))))
+ output.write(self._wrapper.fill(
+ '%s; %s %s:' % (date, author, ', '.join(changed))))
# but feel free to break commit messages there
self._wrapper.break_on_hyphens = True
- output.write(_unicode_decode(
- '\n%s\n\n' % '\n'.join(self._wrapper.fill(x) for x in body)))
+ output.write(
+ '\n%s\n\n' % '\n'.join(self._wrapper.fill(x) for x in body))
output.close()