summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-08-14 23:51:29 +0000
committerZac Medico <zmedico@gentoo.org>2009-08-14 23:51:29 +0000
commit945464ab91f07aa8af47884e2246ccb638a8144f (patch)
tree8f3afbff49887bef65796021dff8f8691069914d
parent8bb6daebe7a8b394e360cceb1655e9634f339904 (diff)
downloadportage-945464ab91f07aa8af47884e2246ccb638a8144f.tar.gz
portage-945464ab91f07aa8af47884e2246ccb638a8144f.tar.bz2
portage-945464ab91f07aa8af47884e2246ccb638a8144f.zip
Add a portage._content_encoding constant, set to utf_8.
svn path=/main/trunk/; revision=14056
-rw-r--r--pym/portage/__init__.py17
-rw-r--r--pym/portage/manifest.py7
2 files changed, 14 insertions, 10 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 8f59a3978..9b7c6c01f 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -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,
diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 403e01115..cc02ddfcc 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -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: