.BR package.unmask
Just like package.mask above, except here you list packages you want to
unmask. Useful for overriding the global package.mask file (see
-below). Note that this does not override packages that are masked via
+above). Note that this does not override packages that are masked via
KEYWORDS.
.TP
.BR package.use
# broken symlink or file removed by a concurrent process
writemsg("!!! File Not Found: '%s'\n" % file_path, noiselevel=-1)
continue
+
+ # TODO: Make getconfig() return unicode.
+ unicode_config = {}
+ for k, v in myconfig.iteritems():
+ if not isinstance(k, unicode):
+ k = unicode(k, encoding='utf8', errors='replace')
+ if not isinstance(v, unicode):
+ v = unicode(v, encoding='utf8', errors='replace')
+ unicode_config[k] = v
+ myconfig = unicode_config
+ del unicode_config
+
config_list.append(myconfig)
if "SPACE_SEPARATED" in myconfig:
space_separated.update(myconfig["SPACE_SEPARATED"].split())
""" epatch will just grab all the patches out of a directory, so we have to
make sure there aren't any foreign files that it might grab."""
filesdir = os.path.join(pkgdir, "files")
+ if isinstance(filesdir, unicode):
+ # Avoid UnicodeDecodeError raised from
+ # os.path.join when called by os.walk.
+ filesdir = filesdir.encode('utf_8', 'replace')
+
for parent, dirs, files in os.walk(filesdir):
for d in dirs:
if d.startswith(".") or d == "CVS":
os.system("chflags -R nosunlnk,nouunlnk %s 2>/dev/null" % \
(_shell_quote(mysettings["D"]),))
- for parent, dirs, files in os.walk(mysettings["D"]):
+ destdir = mysettings["D"]
+ if isinstance(destdir, unicode):
+ # Avoid UnicodeDecodeError raised from
+ # os.path.join when called by os.walk.
+ destdir = destdir.encode('utf_8', 'replace')
+
+ for parent, dirs, files in os.walk(destdir):
for fname in chain(dirs, files):
fpath = os.path.join(parent, fname)
mystat = os.lstat(fpath)
decode=utf8decode,
incrementalencoder=Utf8IncrementalEncoder,
incrementaldecoder=Utf8IncrementalDecoder,
- streamreader=Utf8StreamWriter,
- streamwriter=Utf8StreamReader,
+ streamreader=Utf8StreamReader,
+ streamwriter=Utf8StreamWriter,
)
for alias in ('utf_8', 'u8', 'utf', 'utf8', 'utf8_ucs2', 'utf8_ucs4'):
return os.path.exists(self.__get_path(cpv))
def __iter__(self):
- for root,dirs,files in os.walk(self.portdir):
+
+ portdir = self.portdir
+ if isinstance(portdir, unicode):
+ # Avoid UnicodeDecodeError raised from
+ # os.path.join when called by os.walk.
+ portdir = portdir.encode('utf_8', 'replace')
+
+ for root, dirs, files in os.walk(portdir):
for file in files:
if file[-7:] == '.ebuild':
cat = os.path.basename(os.path.dirname(root))
h = self._new_hash()
# Always use a constant utf_8 encoding here, since
# the "default" encoding can change.
- h.update(s)
+ h.update(s.encode('utf_8', 'replace'))
h = h.hexdigest()
h = h[-self._hex_chars:]
h = int(h, 16)
myfilelist = []
mylinklist = []
paths_with_newlines = []
+
+ if isinstance(srcroot, unicode):
+ # Avoid UnicodeDecodeError raised from
+ # os.path.join when called by os.walk.
+ srcroot = srcroot.encode('utf_8', 'replace')
+
srcroot_len = len(srcroot)
def onerror(e):
raise
@rtype: list
@returns: List of files to process
"""
+
+ if isinstance(filename, unicode):
+ # Avoid UnicodeDecodeError raised from
+ # os.path.join when called by os.walk.
+ filename = filename.encode('utf_8', 'replace')
+
try:
st = os.stat(filename)
except OSError:
cpvlist = []
pn = os.path.basename(self.pkgdir.rstrip(os.path.sep))
cat = self._pkgdir_category()
- for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(self.pkgdir):
+
+ 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:
if f[:1] == ".":
continue
self.fhashdict[mytype][f] = perform_multiple_checksums(self.pkgdir+f, self.hashes)
recursive_files = []
- cut_len = len(os.path.join(self.pkgdir, "files") + os.sep)
- for parentdir, dirs, files in os.walk(os.path.join(self.pkgdir, "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:
full_path = os.path.join(parentdir, f)
recursive_files.append(full_path[cut_len:])
directory = self._repopath_sub.sub(trees["porttree"].dbapi.treemap[match.groupdict()["reponame"]], directory)
except KeyError:
raise SetConfigError(_("Could not find repository '%s'") % match.groupdict()["reponame"])
+
+ if isinstance(directory, unicode):
+ # Avoid UnicodeDecodeError raised from
+ # os.path.join when called by os.walk.
+ directory_unicode = directory
+ directory = directory.encode('utf_8', 'replace')
+ else:
+ directory_unicode = unicode(directory,
+ encoding='utf_8', errors='replace')
+
if os.path.isdir(directory):
directory = normalize_path(directory)
for parent, dirs, files in os.walk(directory):
+ if not isinstance(parent, unicode):
+ parent = unicode(parent,
+ encoding='utf_8', errors='replace')
for d in dirs[:]:
if d[:1] == '.':
dirs.remove(d)
if filename.endswith(".metadata"):
continue
filename = os.path.join(parent,
- filename)[1 + len(directory):]
+ filename)[1 + len(directory_unicode):]
myname = name_pattern.replace("$name", filename)
myname = myname.replace("${name}", filename)
rValue[myname] = StaticFileSet(
TEST_FILE = '__test__'
suite = unittest.TestSuite()
- basedir = os.path.dirname(__file__)
+ basedir = os.path.dirname(os.path.realpath(__file__))
testDirs = []
# the os.walk help mentions relative paths as being quirky
# I was tired of adding dirs to the list, so now we add __test__
# to each dir we want tested.
- for root, dirs, files in os.walk(os.getcwd()):
+ for root, dirs, files in os.walk(basedir):
if ".svn" in dirs:
dirs.remove('.svn')
if TEST_FILE in files:
protect - list of paths from CONFIG_PROTECT
protect_mask - list of paths from CONFIG_PROTECT_MASK
update_iter - list of update commands as returned from parse_updates()"""
+
+ if isinstance(config_root, unicode):
+ # Avoid UnicodeDecodeError raised from
+ # os.path.join when called by os.walk.
+ config_root = config_root.encode('utf_8', 'replace')
+
config_root = normalize_path(config_root)
update_files = {}
file_contents = {}
Returns True if all permissions are applied and False if some are left
unapplied."""
+ if isinstance(top, unicode):
+ # Avoid UnicodeDecodeError raised from
+ # os.path.join when called by os.walk.
+ top = top.encode('utf_8', 'replace')
+
if onerror is None:
# Default behavior is to dump errors to stderr so they won't
# go unnoticed. Callers can pass in a quiet instance.