diff options
author | Paul Varner <fuzzyray@gentoo.org> | 2015-11-24 13:07:33 -0600 |
---|---|---|
committer | Paul Varner <fuzzyray@gentoo.org> | 2015-11-24 13:07:33 -0600 |
commit | c9a117bebeb04efcb731e47a12e79c4c8d065896 (patch) | |
tree | 6db392af53510002fce752a07b5c9d79daafddea /pym/gentoolkit/equery/uses.py | |
parent | Fix spelling error (diff) | |
download | gentoolkit-c9a117bebeb04efcb731e47a12e79c4c8d065896.tar.gz gentoolkit-c9a117bebeb04efcb731e47a12e79c4c8d065896.tar.bz2 gentoolkit-c9a117bebeb04efcb731e47a12e79c4c8d065896.zip |
Change all open() calls to use Unicode.
We are using the following import from portage:
from portage import _encodings, _unicode_decode, _unicode_encode
A generalized call using the definitions from portage looks like:
with open(_unicode_encode(path), encoding=_encodings['fs']) as open_file
The portage code has been in place since 2013 and using the definitions
from portage ensures we maintain compatibility if portage changes.
All portage versions in the tree contain the above code.
Diffstat (limited to 'pym/gentoolkit/equery/uses.py')
-rw-r--r-- | pym/gentoolkit/equery/uses.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pym/gentoolkit/equery/uses.py b/pym/gentoolkit/equery/uses.py index cedac96..7717710 100644 --- a/pym/gentoolkit/equery/uses.py +++ b/pym/gentoolkit/equery/uses.py @@ -21,6 +21,7 @@ from getopt import gnu_getopt, GetoptError from glob import glob from portage import settings +from portage import _encodings, _unicode_decode, _unicode_encode import gentoolkit.pprinter as pp from gentoolkit import errors @@ -135,7 +136,7 @@ def get_global_useflags(): # Get global USE flag descriptions try: path = os.path.join(settings["PORTDIR"], 'profiles', 'use.desc') - with open(path) as open_file: + with open(_unicode_encode(path), encoding=_encodings['fs']) as open_file: for line in open_file: if line.startswith('#'): continue @@ -155,7 +156,7 @@ def get_global_useflags(): for path in glob(os.path.join(settings["PORTDIR"], 'profiles', 'desc', '*.desc')): try: - with open(path) as open_file: + with open(_unicode_encode(path), encoding=_encodings['fs']) as open_file: for line in open_file: if line.startswith('#'): continue |