dead_nodes = set()
if self._global_cleanse:
try:
- for cpv in trg_cache.keys():
+ for cpv in trg_cache:
cp = cpv_getkey(cpv)
if cp is None:
self.returncode |= 1
else:
cp_set = self._cp_set
try:
- for cpv in trg_cache.keys():
+ for cpv in trg_cache:
cp = cpv_getkey(cpv)
if cp is None:
self.returncode |= 1
"cleanresume":CleanResume
}
- module_names = list(modules.keys())
+ module_names = list(modules)
module_names.sort()
module_names.insert(0, "all")
fd1.write(color(myglsa.nr) + " " + color(status) + " " + color(access) + myglsa.title + " (")
if not verbose:
- for pkg in list(myglsa.packages.keys())[:3]:
+ for pkg in list(myglsa.packages)[:3]:
fd1.write(" " + pkg + " ")
if len(myglsa.packages) > 3:
fd1.write("... ")
else:
- for pkg in myglsa.packages.keys():
+ for pkg in myglsa.packages:
mylist = vardb.match(portage.dep_getkey(str(pkg)))
if len(mylist) > 0:
pkg = color(" ".join(mylist))
'scan' : 'Scan directory tree for QA issues'
}
- mode_keys = list(modes.keys())
+ mode_keys = list(modes)
mode_keys.sort()
parser = RepomanOptionParser(formatter=RepomanHelpFormatter(), usage="%prog [options] [mode]")
parser.add_option('--without-mask', dest='without_mask', action='store_true',
default=False, help='behave as if no package.mask entries exist (not allowed with commit mode)')
- parser.add_option('--mode', type='choice', dest='mode', choices=list(modes.keys()),
+ parser.add_option('--mode', type='choice', dest='mode', choices=list(modes),
help='specify which mode repoman will run in (default=full)')
parser.on_tail("\n " + green("Modes".ljust(20) + " Description\n"))
parser.on_tail("\n " + green("QA keyword".ljust(20) + " Description\n"))
- sorted_qa = list(qahelp.keys())
+ sorted_qa = list(qahelp)
sorted_qa.sort()
for k in sorted_qa:
parser.on_tail(" %s %s\n" % (k.ljust(20), qahelp[k]))
"upstream.workaround":"The ebuild works around an upstream bug, an upstream bug should be filed and tracked in bugs.gentoo.org"
}
-qacats = list(qahelp.keys())
+qacats = list(qahelp)
qacats.sort()
qawarnings = set((
if self._global_cleanse:
for mytree in portdb.porttrees:
try:
- dead_nodes[mytree] = set(portdb.auxdb[mytree].keys())
+ dead_nodes[mytree] = set(portdb.auxdb[mytree])
except CacheError as e:
portage.writemsg("Error listing cache entries for " + \
"'%s': %s, continuing...\n" % (mytree, e),
for mytree in portdb.porttrees:
try:
dead_nodes[mytree] = set(cpv for cpv in \
- portdb.auxdb[mytree].keys() \
+ portdb.auxdb[mytree] \
if cpv_getkey(cpv) in cp_set)
except CacheError as e:
portage.writemsg("Error listing cache entries for " + \
select_args = self._select_args
if select_args is None:
- select_args = [list(self._registered.keys()), [], []]
+ select_args = [list(self._registered), [], []]
if timeout is not None:
select_args = select_args[:]
libtool_vers = ",".join(trees["/"]["vartree"].dbapi.match("sys-devel/libtool"))
if "--verbose" in myopts:
- myvars=list(settings.keys())
+ myvars = list(settings)
else:
myvars = ['GENTOO_MIRRORS', 'CONFIG_PROTECT', 'CONFIG_PROTECT_MASK',
'PORTDIR', 'DISTDIR', 'PKGDIR', 'PORTAGE_TMPDIR',
for tree_data in porttrees_data:
try:
- dead_nodes = set(tree_data.dest_db.keys())
+ dead_nodes = set(tree_data.dest_db)
except CacheError as e:
writemsg_level("Error listing cache entries for " + \
"'%s': %s, continuing...\n" % (tree_data.path, e),
slotmap[myslot][vartree.dbapi.cpv_counter(mypkg)] = mypkg
for myslot in slotmap:
- counterkeys = list(slotmap[myslot].keys())
+ counterkeys = list(slotmap[myslot])
if not counterkeys:
continue
counterkeys.sort()
else:
self.make_defaults_use.append("")
self.mygcfg = stack_dicts(mygcfg_dlists,
- incrementals=portage.const.INCREMENTALS, ignore_none=1)
+ incrementals=portage.const.INCREMENTALS)
if self.mygcfg is None:
self.mygcfg = {}
self.configlist.append(self.mygcfg)
for i, pkgprofileuse_dict in enumerate(self.pkgprofileuse):
cpdict = pkgprofileuse_dict.get(cp)
if cpdict:
- keys = list(cpdict.keys())
+ keys = list(cpdict)
while keys:
bestmatch = best_match_to_list(cpv_slot, keys)
if bestmatch:
self.puse = ""
cpdict = self.pusedict.get(cp)
if cpdict:
- keys = list(cpdict.keys())
+ keys = list(cpdict)
while keys:
self.pusekey = best_match_to_list(cpv_slot, keys)
if self.pusekey:
for i, pusemask_dict in enumerate(self.pusemask_list):
cpdict = pusemask_dict.get(cp)
if cpdict:
- keys = list(cpdict.keys())
+ keys = list(cpdict)
while keys:
best_match = best_match_to_list(pkg, keys)
if best_match:
for i, puseforce_dict in enumerate(self.puseforce_list):
cpdict = puseforce_dict.get(cp)
if cpdict:
- keys = list(cpdict.keys())
+ keys = list(cpdict)
while keys:
best_match = best_match_to_list(pkg, keys)
if best_match:
if cpdict:
accept_license = list(self._accept_license)
cpv_slot = "%s:%s" % (cpv, metadata["SLOT"])
- for atom in match_to_list(cpv_slot, list(cpdict.keys())):
+ for atom in match_to_list(cpv_slot, list(cpdict)):
accept_license.extend(cpdict[atom])
licenses = set(flatten(dep.use_reduce(dep.paren_reduce(
if cpdict:
accept_properties = list(self._accept_properties)
cpv_slot = "%s:%s" % (cpv, metadata["SLOT"])
- for atom in match_to_list(cpv_slot, list(cpdict.keys())):
+ for atom in match_to_list(cpv_slot, list(cpdict)):
accept_properties.extend(cpdict[atom])
properties = set(flatten(dep.use_reduce(dep.paren_reduce(
mysettings.get("PORTAGE_QUIET", None) == "1"
digests = mydigests.get(myfile)
if digests:
- digests = list(digests.keys())
+ digests = list(digests)
digests.sort()
eout.ebegin(
"%s %s ;-)" % (myfile, " ".join(digests)))
writemsg(_("!!! Permission Denied: %s\n") % (e,), noiselevel=-1)
return 0
if "assume-digests" not in mysettings.features:
- distlist = list(mf.fhashdict.get("DIST", {}).keys())
+ distlist = list(mf.fhashdict.get("DIST", {}))
distlist.sort()
auto_assumed = []
for filename in distlist:
self.portdb = mydbapi
def __getitem__(self, pkg_key):
"""Returns the complete fetch list for a given package."""
- return list(self.portdb.getFetchMap(pkg_key, mytree=self.mytree).keys())
+ return list(self.portdb.getFetchMap(pkg_key, mytree=self.mytree))
def __contains__(self, cpv):
- return cpv in list(self.keys())
+ return cpv in self.__iter__()
def has_key(self, pkg_key):
"""Returns true if the given package exists within pkgdir."""
return pkg_key in self
mtimedbkeys = set(("info", "ldpath", "resume", "resume_backup",
"starttime", "updates", "version"))
- for k in list(d.keys()):
+ for k in list(d):
if k not in mtimedbkeys:
writemsg(_("Deleting invalid mtimedb key: %s\n") % str(k))
del d[k]
# License: GPL2
# $Id$
-anydbm_module = __import__("anydbm")
+try:
+ anydbm_module = __import__("anydbm")
+except ImportError:
+ # python 3.x
+ import dbm as anydbm_module
try:
import cPickle as pickle
except ImportError:
self._db_path = os.path.join(self.location, fs_template.gen_label(self.location, self.label)+default_db)
self.__db = None
try:
- self.__db = anydbm_module.open(
- _unicode_encode(self._db_path), 'w', self._perms)
+ # dbm.open() will not work with bytes in python-3.1:
+ # TypeError: can't concat bytes to str
+ self.__db = anydbm_module.open(self._db_path,
+ 'w', self._perms)
except anydbm_module.error:
# XXX handle this at some point
try:
# try again if failed
try:
if self.__db == None:
- self.__db = anydbm_module.open(
- _unicode_encode(self._db_path), 'c', self._perms)
+ # dbm.open() will not work with bytes in python-3.1:
+ # TypeError: can't concat bytes to str
+ self.__db = anydbm_module.open(self._db_path,
+ 'c', self._perms)
except anydbm_module.error as e:
raise cache_errors.InitializationError(self.__class__, e)
self._ensure_access(self._db_path)
def __iter__(self):
- for k in self.new.keys():
+ for k in self.new:
yield k
- for k in self.orig.keys():
+ for k in self.orig:
if k not in self.blacklist and k not in self.new:
yield k
raise cache_errors.ReadOnlyRestriction()
if self.cleanse_keys:
d=ProtectedDict(values)
- for k in list(d.keys()):
- if d[k] == '':
+ for k, v in list(d.items()):
+ if not v:
del d[k]
if self.serialize_eclasses and "_eclasses_" in values:
d["_eclasses_"] = serialize_eclasses(d["_eclasses_"])
return cpv in self
def keys(self):
- return tuple(self.keys())
+ return list(self)
def iterkeys(self):
return iter(self)
def iteritems(self):
- for x in self.keys():
+ for x in self:
yield (x, self[x])
def items(self):
if key not in self.__known_keys:
raise InvalidRestriction(key, match, "Key isn't valid")
- for cpv in self.keys():
+ for cpv in self:
cont = True
vals = self[cpv]
for key, match in restricts.items():
return mydict
def get_valid_checksum_keys():
- return list(hashfunc_map.keys())
+ return list(hashfunc_map)
def get_hash_origin(hashtype):
if hashtype not in hashfunc_map:
entries["dirs"][mysplit[1]]["flags"]=mysplit[2:]
if recursive:
rentries=getentries(mydir+"/"+mysplit[1],recursive)
- #print rentries.keys()
- #print entries["files"].keys()
- #print entries["files"][mysplit[1]]
entries["dirs"][mysplit[1]]["dirs"]=rentries["dirs"]
entries["dirs"][mysplit[1]]["files"]=rentries["files"]
else:
print("File of unknown type:",mydir+"/"+file)
print()
return entries
-
-#class cvstree:
-# def __init__(self,basedir):
-# self.refdir=os.cwd()
-# self.basedir=basedir
-# self.entries={}
-# self.entries["dirs"]={}
-# self.entries["files"]={}
-# self.entries["dirs"][self.basedir]=getentries(self.basedir)
-# self.getrealdirs(self.dirs, self.files)
-# def getrealdirs(self,dirs,files):
-# for mydir in dirs.keys():
-# list = os.listdir(
-
-
self.settings["PORTAGE_BINHOST"], chunk_size=chunk_size)
#writemsg(green(" -- DONE!\n\n"))
- for mypkg in self.remotepkgs.keys():
+ for mypkg in list(self.remotepkgs):
if "CATEGORY" not in self.remotepkgs[mypkg]:
#old-style or corrupt package
writemsg(_("!!! Invalid remote binary package: %s\n") % mypkg,
y == "CVS":
continue
d[x+"/"+y] = None
- l = list(d.keys())
+ l = list(d)
l.sort()
return l
(mycp, self.mysettings["PORTAGE_CONFIGROOT"]), noiselevel=-1)
mylist = []
else:
- mylist = list(d.keys())
+ mylist = list(d)
# Always sort in ascending order here since it's handy
# and the result can be easily cached and reused.
self._cpv_sort_ascending(mylist)
os = _os_merge
- for cps in self._data.keys():
+ for cps in list(self._data):
cpv, counter, paths = self._data[cps]
paths = [f for f in paths \
if os.path.exists(os.path.join(self._root, f.lstrip(os.sep)))]
self.invalidentry(self.getpath(y))
continue
d[mysplit[0]+"/"+mysplit[1]] = None
- return list(d.keys())
+ return list(d)
def checkblockers(self, origdep):
pass
secpass >= 2:
self._owners.populate() # index any unindexed contents
valid_nodes = set(self.cpv_all())
- for cpv in self._aux_cache["packages"].keys():
+ for cpv in list(self._aux_cache["packages"]):
if cpv not in valid_nodes:
del self._aux_cache["packages"][cpv]
del self._aux_cache["modified"]
if pkgfiles:
self.updateprotect()
- mykeys = list(pkgfiles.keys())
+ mykeys = list(pkgfiles)
mykeys.sort()
mykeys.reverse()
curval = 0
if onProgress:
onProgress(maxval, 0)
- paths = list(contents.keys())
+ paths = list(contents)
paths.sort()
for path in paths:
curval += 1
return list(self.cpdict)
def cpv_all(self):
- return list(self.cpvdict.keys())
+ return list(self.cpvdict)
def cpv_inject(self, mycpv, metadata=None):
"""Adds a cpv to the list of available packages. See the
else:
all_logentries[cpv] = ebuild_logentries
- for key in list(_preserve_logentries.keys()):
+ for key in list(_preserve_logentries):
if key in all_logentries:
all_logentries[key] = _merge_logentries(_preserve_logentries[key], all_logentries[key])
else:
# look at the phases listed in our logentries to figure out what action was performed
action = _("merged")
- for phase in logentries.keys():
+ for phase in logentries:
# if we found a *rm phase assume that the package was unmerged
if phase in ["postrm", "prerm"]:
action = _("unmerged")
# if we think that the package was unmerged, make sure there was no unexpected
# phase recorded to avoid misinformation
if action == _("unmerged"):
- for phase in logentries.keys():
+ for phase in logentries:
if phase not in ["postrm", "prerm", "other"]:
action = _("unknown")
if self.modified:
self.header["TIMESTAMP"] = str(long(time.time()))
self.header["PACKAGES"] = str(len(self.packages))
- keys = list(self.header.keys())
+ keys = list(self.header)
keys.sort()
self._writepkgindex(pkgfile, [(k, self.header[k]) \
for k in keys if self.header[k]])
for k, v in self._default_pkg_data.items():
if metadata.get(k) == v:
metadata.pop(k, None)
- keys = list(metadata.keys())
+ keys = list(metadata)
keys.sort()
self._writepkgindex(pkgfile,
[(k, metadata[k]) for k in keys if metadata[k]])
outstream.write(_("Announced on: %s\n") % self.announced)
outstream.write(_("Last revised on: %s : %02d\n\n") % (self.revised, self.count))
if self.glsatype == "ebuild":
- for k in self.packages.keys():
+ for k in self.packages:
pkg = self.packages[k]
for path in pkg:
vul_vers = "".join(path["vul_vers"])
@returns: True if the system is affected, False if not
"""
rValue = False
- for k in self.packages.keys():
+ for k in self.packages:
pkg = self.packages[k]
for path in pkg:
if path["arch"] == "*" or self.config["ARCH"] in path["arch"].split():
@return: list of package-versions that have to be merged
"""
rValue = []
- for pkg in self.packages.keys():
+ for pkg in self.packages:
for path in self.packages[pkg]:
update = getMinUpgrade(path["vul_atoms"], path["unaff_atoms"], \
self.portdbapi, self.vardbapi, minimize=least_change)
class Manifest2Entry(ManifestEntry):
def __str__(self):
myline = " ".join([self.type, self.name, str(self.hashes["size"])])
- myhashkeys = list(self.hashes.keys())
+ myhashkeys = list(self.hashes)
myhashkeys.remove("size")
myhashkeys.sort()
for h in myhashkeys:
return myhashdict
def _createManifestEntries(self):
- mytypes = list(self.fhashdict.keys())
+ mytypes = list(self.fhashdict)
mytypes.sort()
for t in mytypes:
- myfiles = list(self.fhashdict[t].keys())
+ myfiles = list(self.fhashdict[t])
myfiles.sort()
for f in myfiles:
myentry = Manifest2Entry(
type=t, name=f, hashes=self.fhashdict[t][f].copy())
- myhashkeys = list(myentry.hashes.keys())
+ myhashkeys = list(myentry.hashes)
myhashkeys.sort()
for h in myhashkeys:
if h not in ["size"] + portage.const.MANIFEST2_HASH_FUNCTIONS:
rev_transform[atom] = atom
else:
rev_transform[Atom(atom.replace(atom.cp, pkg.cp, 1))] = atom
- best_match = best_match_to_list(pkg, iter(rev_transform.keys()))
+ best_match = best_match_to_list(pkg, iter(rev_transform))
if best_match:
return rev_transform[best_match]
return None
raise SetConfigError(_("no includes or excludes given"))
metadatadb = options.get("metadata-source", "vartree")
- if not metadatadb in trees.keys():
+ if not metadatadb in trees:
raise SetConfigError(_("invalid value '%s' for option metadata-source") % metadatadb)
return cls(trees["vartree"].dbapi,
data = {}
if self.greedy:
atoms = []
- for a in data.keys():
+ for a in data:
matches = self.dbapi.match(a)
for cpv in matches:
atoms.append("%s:%s" % (cpv_getkey(cpv),
# in the latest new slot that may be available.
atoms.append(a)
else:
- atoms = list(data.keys())
+ atoms = iter(data)
self._setAtoms(atoms)
self._mtime = mtime
def load(self):
data, errors = self.loader.load()
- self._setAtoms(list(data.keys()))
+ self._setAtoms(iter(data))
def singleBuilder(self, options, settings, trees):
if not "filename" in options:
raise
del e
data = {}
- atoms = list(data.keys())
+ atoms = list(data)
self._mtime = mtime
atoms_changed = True
else:
raise
del e
data = {}
- nonatoms = list(data.keys())
+ nonatoms = list(data)
self._mtime2 = mtime
atoms_changed = True
else:
Returns a single dict."""
final_dict = None
for mydict in dicts:
- if mydict is None:
- if ignore_none:
- continue
- else:
- return None
+ if not mydict:
+ continue
if final_dict is None:
final_dict = {}
- for y in list(mydict.keys()):
- if True:
- if y in final_dict and (incremental or (y in incrementals)):
- final_dict[y] += " "+mydict[y][:]
- else:
- final_dict[y] = mydict[y][:]
- mydict[y] = " ".join(mydict[y].split()) # Remove extra spaces.
+ for k, v in mydict.items():
+ if k in final_dict and (incremental or (k in incrementals)):
+ final_dict[k] += " " + v
+ else:
+ final_dict[k] = v
return final_dict
def stack_lists(lists, incremental=1):
new_list[y] = True
else:
new_list[y] = True
- return list(new_list.keys())
+ return list(new_list)
def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1):
"""