Add a portage._content_encoding constant, set to utf_8.
authorZac Medico <zmedico@gentoo.org>
Fri, 14 Aug 2009 23:51:29 +0000 (23:51 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 14 Aug 2009 23:51:29 +0000 (23:51 -0000)
svn path=/main/trunk/; revision=14056

pym/portage/__init__.py
pym/portage/manifest.py

index 8f59a39782fd65d19219e043ca677d4fa6f758ff..9b7c6c01f82725711e6c84269223e196ad5b1ba1 100644 (file)
@@ -118,12 +118,20 @@ except ImportError, e:
        sys.stderr.write("    "+str(e)+"\n\n")
        raise
 
-def _unicode_encode(s, encoding='utf_8', errors='replace'):
+# Assume utf_8 encoding for content of all files.
+_content_encoding = 'utf_8'
+
+# Assume utf_8 fs encoding everywhere except in merge code.
+_fs_encoding = 'utf_8'
+
+_merge_encoding = sys.getfilesystemencoding()
+
+def _unicode_encode(s, encoding=_content_encoding, errors='replace'):
        if isinstance(s, unicode):
                s = s.encode(encoding, errors)
        return s
 
-def _unicode_decode(s, encoding='utf_8', errors='replace'):
+def _unicode_decode(s, encoding=_content_encoding, errors='replace'):
        if not isinstance(s, unicode):
                if sys.hexversion < 0x3000000:
                        if isinstance(s, basestring):
@@ -197,11 +205,6 @@ class _unicode_module_wrapper(object):
                        result = _unicode_func_wrapper(result, encoding=encoding)
                return result
 
-# Assume utf_8 fs encoding everywhere except in merge code.
-_fs_encoding = 'utf_8'
-
-_merge_encoding = sys.getfilesystemencoding()
-
 import os as _os
 _os_overrides = {
        id(_os.fdopen)        : _os.fdopen,
index 403e01115afb2043c542aeb2f8388a059bd2d8cd..cc02ddfccd409cd4132451a38d3b8c780e5e3db2 100644 (file)
@@ -12,6 +12,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
 )
 
 from portage import os
+from portage import _content_encoding
 from portage import _fs_encoding
 from portage import _unicode_decode
 from portage import _unicode_encode
@@ -144,7 +145,7 @@ class Manifest(object):
                try:
                        fd = codecs.open(_unicode_encode(file_path,
                                encoding=_fs_encoding, errors='strict'), mode='r',
-                               encoding='utf_8', errors='replace')
+                               encoding=_content_encoding, errors='replace')
                        if myhashdict is None:
                                myhashdict = {}
                        self._parseDigests(fd, myhashdict=myhashdict, **kwargs)
@@ -232,7 +233,7 @@ class Manifest(object):
                                try:
                                        f = codecs.open(_unicode_encode(self.getFullname(),
                                                encoding=_fs_encoding, errors='strict'),
-                                               mode='r', encoding='utf_8', errors='replace')
+                                               mode='r', encoding=_content_encoding, errors='replace')
                                        oldentries = list(self._parseManifestLines(f))
                                        f.close()
                                        if len(oldentries) == len(myentries):
@@ -522,7 +523,7 @@ class Manifest(object):
                        return rVal
                myfile = codecs.open(_unicode_encode(mfname,
                        encoding=_fs_encoding, errors='strict'),
-                       mode='r', encoding='utf_8', errors='replace')
+                       mode='r', encoding=_content_encoding, errors='replace')
                lines = myfile.readlines()
                myfile.close()
                for l in lines: