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):
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,
)
from portage import os
+from portage import _content_encoding
from portage import _fs_encoding
from portage import _unicode_decode
from portage import _unicode_encode
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)
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):
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: