From 71235479ab208318dff391420f9695f5cfaa9594 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 18 Jan 2013 13:33:08 -0800 Subject: Use unicode_literals more. This helps to ensure consistent results, regardless of whether we're using Python 2 or Python 3. --- pym/portage/dbapi/__init__.py | 4 +++- pym/portage/dbapi/_expand_new_virt.py | 4 +++- pym/portage/dbapi/bintree.py | 12 +++++++----- pym/portage/dbapi/cpv_expand.py | 4 +++- pym/portage/dbapi/dep_expand.py | 4 +++- pym/portage/dbapi/porttree.py | 2 ++ pym/portage/dbapi/vartree.py | 20 +++++++++++--------- pym/portage/dbapi/virtual.py | 3 ++- 8 files changed, 34 insertions(+), 19 deletions(-) (limited to 'pym/portage/dbapi') diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py index 49b72937d..5828bcacd 100644 --- a/pym/portage/dbapi/__init__.py +++ b/pym/portage/dbapi/__init__.py @@ -1,6 +1,8 @@ -# Copyright 1998-2012 Gentoo Foundation +# Copyright 1998-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +from __future__ import unicode_literals + __all__ = ["dbapi"] import re diff --git a/pym/portage/dbapi/_expand_new_virt.py b/pym/portage/dbapi/_expand_new_virt.py index 95b2c28cd..9aa603d11 100644 --- a/pym/portage/dbapi/_expand_new_virt.py +++ b/pym/portage/dbapi/_expand_new_virt.py @@ -1,6 +1,8 @@ -# Copyright 2011-2012 Gentoo Foundation +# Copyright 2011-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +from __future__ import unicode_literals + import portage from portage.dep import Atom, _get_useflag_re from portage.eapi import _get_eapi_attrs diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index f6fc11498..875e95515 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -1,6 +1,8 @@ -# Copyright 1998-2012 Gentoo Foundation +# Copyright 1998-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +from __future__ import unicode_literals + __all__ = ["bindbapi", "binarytree"] import portage @@ -138,15 +140,15 @@ class bindbapi(fakedbapi): if myval: mydata[x] = " ".join(myval.split()) - if not mydata.setdefault('EAPI', _unicode_decode('0')): - mydata['EAPI'] = _unicode_decode('0') + if not mydata.setdefault('EAPI', '0'): + mydata['EAPI'] = '0' if cache_me: aux_cache = self._aux_cache_slot_dict() for x in self._aux_cache_keys: - aux_cache[x] = mydata.get(x, _unicode_decode('')) + aux_cache[x] = mydata.get(x, '') self._aux_cache[mycpv] = aux_cache - return [mydata.get(x, _unicode_decode('')) for x in wants] + return [mydata.get(x, '') for x in wants] def aux_update(self, cpv, values): if not self.bintree.populated: diff --git a/pym/portage/dbapi/cpv_expand.py b/pym/portage/dbapi/cpv_expand.py index 947194cca..70ee78245 100644 --- a/pym/portage/dbapi/cpv_expand.py +++ b/pym/portage/dbapi/cpv_expand.py @@ -1,6 +1,8 @@ -# Copyright 2010-2011 Gentoo Foundation +# Copyright 2010-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +from __future__ import unicode_literals + __all__ = ["cpv_expand"] import portage diff --git a/pym/portage/dbapi/dep_expand.py b/pym/portage/dbapi/dep_expand.py index bb211c739..3de5d8fc3 100644 --- a/pym/portage/dbapi/dep_expand.py +++ b/pym/portage/dbapi/dep_expand.py @@ -1,6 +1,8 @@ -# Copyright 2010-2012 Gentoo Foundation +# Copyright 2010-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +from __future__ import unicode_literals + __all__ = ["dep_expand"] import re diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index cf4b14231..321b6758a 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -1,6 +1,8 @@ # Copyright 1998-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +from __future__ import unicode_literals + __all__ = [ "close_portdbapi_caches", "FetchlistDict", "portagetree", "portdbapi" ] diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 09130fb38..30add8a89 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1,6 +1,8 @@ # Copyright 1998-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +from __future__ import unicode_literals + __all__ = [ "vardbapi", "vartree", "dblink"] + \ ["write_contents", "tar_contents"] @@ -594,7 +596,7 @@ class vardbapi(dbapi): getattr(e, 'errno', None) in (errno.ENOENT, errno.EACCES): pass else: - writemsg(_unicode_decode(_("!!! Error loading '%s': %s\n")) % \ + writemsg(_("!!! Error loading '%s': %s\n") % \ (self._aux_cache_filename, e), noiselevel=-1) del e @@ -714,7 +716,7 @@ class vardbapi(dbapi): if _get_slot_re(eapi_attrs).match(mydata['SLOT']) is None: # Empty or invalid slot triggers InvalidAtom exceptions when # generating slot atoms for packages, so translate it to '0' here. - mydata['SLOT'] = _unicode_decode('0') + mydata['SLOT'] = '0' return [mydata[x] for x in wants] @@ -750,7 +752,7 @@ class vardbapi(dbapi): self._aux_cache_keys_re.match(x) is None: env_keys.append(x) continue - myd = _unicode_decode('') + myd = '' # Preserve \n for metadata that is known to # contain multiple lines. @@ -764,13 +766,13 @@ class vardbapi(dbapi): for k in env_keys: v = env_results.get(k) if v is None: - v = _unicode_decode('') + v = '' if self._aux_multi_line_re.match(k) is None: v = " ".join(v.split()) results[k] = v if results.get("EAPI") == "": - results[_unicode_decode("EAPI")] = _unicode_decode('0') + results["EAPI"] = '0' return results @@ -1607,7 +1609,7 @@ class dblink(object): if myroot == os.path.sep: myroot = None # used to generate parent dir entries - dir_entry = (_unicode_decode("dir"),) + dir_entry = ("dir",) eroot_split_len = len(self.settings["EROOT"].split(os.sep)) - 1 pos = 0 errors = [] @@ -1896,7 +1898,7 @@ class dblink(object): showMessage(_("!!! FAILED prerm: %s\n") % \ os.path.join(self.dbdir, "EAPI"), level=logging.ERROR, noiselevel=-1) - showMessage(_unicode_decode("%s\n") % (eapi_unsupported,), + showMessage("%s\n" % (eapi_unsupported,), level=logging.ERROR, noiselevel=-1) elif os.path.isfile(myebuildpath): phase = EbuildPhase(background=background, @@ -3963,7 +3965,7 @@ class dblink(object): encoding=_encodings['fs'], errors='strict'), mode='w', encoding=_encodings['repo.content'], errors='backslashreplace') as f: - f.write(_unicode_decode(str(counter))) + f.write("%s" % counter) self.updateprotect() @@ -4859,7 +4861,7 @@ class dblink(object): mode='w', encoding=_encodings['repo.content'], errors='backslashreplace') as f: for x in mylist: - f.write(_unicode_decode(x + "\n")) + f.write("%s\n" % x) def isregular(self): "Is this a regular package (does it have a CATEGORY file? A dblink can be virtual *and* regular)" diff --git a/pym/portage/dbapi/virtual.py b/pym/portage/dbapi/virtual.py index 30d6c227f..ba9745c2a 100644 --- a/pym/portage/dbapi/virtual.py +++ b/pym/portage/dbapi/virtual.py @@ -1,6 +1,7 @@ -# Copyright 1998-2012 Gentoo Foundation +# Copyright 1998-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +from __future__ import unicode_literals from portage.dbapi import dbapi from portage.dbapi.dep_expand import dep_expand -- cgit v1.2.3-1-g7c22