INVALID_ENV_FILE, CUSTOM_MIRRORS_FILE, CONFIG_MEMORY_FILE,\
INCREMENTALS, EAPI, MISC_SH_BINARY, REPO_NAME_LOC, REPO_NAME_FILE
- from portage.manifest import Manifest
- import portage.exception
from portage.localization import _
except ImportError, e:
import shutil
shutil = _unicode_module_wrapper(shutil)
+# Imports below this point rely on the above unicode wrapper definitions.
+
try:
import portage._selinux as selinux
except OSError, e:
except ImportError:
pass
+from portage.manifest import Manifest
+
# ===========================================================================
# END OF IMPORTS -- END OF IMPORTS -- END OF IMPORTS -- END OF IMPORTS -- END
# ===========================================================================
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import errno, os
+import codecs
+import errno
import portage
portage.proxy.lazyimport.lazyimport(globals(),
'portage.util:write_atomic',
)
-from portage.exception import *
+from portage import os
+from portage import _unicode_decode
+from portage import _unicode_encode
+from portage.exception import DigestException, FileNotFound, \
+ InvalidDataType, MissingParameter, PermissionDenied, \
+ PortageException, PortagePackageException
class FileNotInManifestException(PortageException):
pass
Do not parse Manifest file if from_scratch == True (only for internal use)
The fetchlist_dict parameter is required only for generation of
a Manifest (not needed for parsing and checking sums)."""
- self.pkgdir = pkgdir.rstrip(os.sep) + os.sep
+ self.pkgdir = _unicode_decode(pkgdir).rstrip(os.sep) + os.sep
self.fhashdict = {}
self.hashes = set()
self.hashes.update(portage.const.MANIFEST2_HASH_FUNCTIONS)
"""Parse a manifest. If myhashdict is given then data will be added too it.
Otherwise, a new dict will be created and returned."""
try:
- fd = open(file_path, "r")
+ fd = codecs.open(_unicode_encode(file_path), mode='r',
+ encoding='utf_8', errors='replace')
if myhashdict is None:
myhashdict = {}
self._parseDigests(fd, myhashdict=myhashdict, **kwargs)
update_manifest = True
if not force:
try:
- f = open(self.getFullname(), "r")
+ f = codecs.open(_unicode_encode(self.getFullname()),
+ mode='r', encoding='utf_8', errors='replace')
oldentries = list(self._parseManifestLines(f))
f.close()
if len(oldentries) == len(myentries):
cat = self._pkgdir_category()
pkgdir = self.pkgdir
- if isinstance(pkgdir, unicode):
- # Avoid UnicodeDecodeError raised from
- # os.path.join when called by os.walk.
- pkgdir = pkgdir.encode('utf_8', 'replace')
for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(pkgdir):
break
for f in pkgdir_files:
+ f = _unicode_decode(f)
if f[:1] == ".":
continue
pf = None
recursive_files = []
pkgdir = self.pkgdir
- if isinstance(pkgdir, unicode):
- # Avoid UnicodeDecodeError raised from
- # os.path.join when called by os.walk.
- pkgdir = pkgdir.encode('utf_8', 'replace')
-
cut_len = len(os.path.join(pkgdir, "files") + os.sep)
for parentdir, dirs, files in os.walk(os.path.join(pkgdir, "files")):
for f in files:
mfname = self.getFullname()
if not os.path.exists(mfname):
return rVal
- myfile = open(mfname, "r")
+ myfile = codecs.open(_unicode_encode(mfname),
+ mode='r', encoding='utf_8', errors='replace')
lines = myfile.readlines()
myfile.close()
for l in lines: