actions = {}
writemsg("\n\n")
-for catpkg in bad.keys():
+for catpkg in bad:
bad[catpkg].sort()
mystr = ""
if (len(sys.argv) > 1) and (sys.argv[1] == "--fix"):
writemsg("These are only directions, at the moment.")
- for catpkg in actions.keys():
+ for catpkg in actions:
action = actions[catpkg]
writemsg("We will now '%s' '%s'..." % (action, catpkg))
#if action ==
else:
continue
- if mybn not in md5sums.keys():
+ if mybn not in md5sums:
portage.util.writemsg("Missing md5sum: %s in %s\n" % (mybn, mycpv))
else:
- if mybn in md5_list.keys():
+ if mybn in md5_list:
if (md5_list[mybn]["MD5"] != md5sums[mybn]["MD5"]) or \
(md5_list[mybn]["size"] != md5sums[mybn]["size"]):
del md5sums[mybn]
#portage.writemsg(str(bn_list)+"\n")
- for x in md5sums.keys():
+ for x in md5sums:
if x not in bn_list:
portage.writemsg("Extra md5sum: %s in %s\n" % (x, mycpv))
print col_list
print
-print str(len(md5_list.keys()))+" unique distfile md5s."
+print str(len(md5_list))+" unique distfile md5s."
print str(len(bn_list))+" unique distfile names."
sys.exit(2)
mylibs = portage.db[argv[0]]["vartree"].dbapi.plib_registry.getPreservedLibs()
rValue = 0
- for cpv in mylibs.keys():
+ for cpv in mylibs:
for path in mylibs[cpv]:
print "%s: %s" % (cpv, path)
rValue = 1
# Show our commands -- we do this by scanning the functions in this
# file, and formatting each functions documentation.
#
- commands = [x for x in globals().keys() if x not in \
+ commands = [x for x in globals() if x not in \
("usage", "__doc__", "__name__", "main", "os", "portage", \
"sys", "__builtins__", "types", "string","exithandler")]
commands.sort()
if not dblnk.exists():
# unmerged by a concurrent process
continue
+ iuse, use = vardb.aux_get(cpv, ["IUSE","USE"])
+ iuse = [ x.lstrip("+-") for x in iuse.split() ]
+ use = use.split()
+ if "bindist" in iuse and "bindist" not in use:
+ eout.ewarn("%s: package was emerged with USE=-bindist!" % cpv)
+ eout.ewarn("%s: it may not be legal to redistribute this." % cpv)
eout.ebegin("Building package for %s" % cpv)
pkgs_for_arg += 1
contents = dblnk.getcontents()
parser.add_option("--umask",
default="0077",
help="umask used during package creation (default is 0077)")
- from portage import settings
- default_opts = settings.get("QUICKPKG_DEFAULT_OPTS","").split()
- options, args = parser.parse_args(default_opts + sys.argv[1:])
+ parser.add_option("--ignore-default-opts",
+ action="store_true",
+ help="do not use the QUICKPKG_DEFAULT_OPTS environment variable")
+ options, args = parser.parse_args(sys.argv[1:])
+ if not options.ignore_default_opts:
+ from portage import settings
+ default_opts = settings.get("QUICKPKG_DEFAULT_OPTS","").split()
+ options, args = parser.parse_args(default_opts + sys.argv[1:])
if not args:
parser.error("no packages atoms given")
try:
if len(sys.argv)>1:
x=1
while x < len(sys.argv):
- if sys.argv[x] in shortmodes.keys():
+ if sys.argv[x] in shortmodes:
sys.argv[x]=shortmodes[sys.argv[x]]
- elif sys.argv[x] in repoman_shortoptions.keys():
+ elif sys.argv[x] in repoman_shortoptions:
sys.argv[x] = repoman_shortoptions[sys.argv[x]]
if sys.argv[x] in modes:
if mymode is None:
xs=x.split(seperator)
if xs[0]==".":
xs=xs[1:]
- if xs[0] not in mygroups.keys():
+ if xs[0] not in mygroups:
mygroups[xs[0]]=[seperator.join(xs[1:])]
else:
mygroups[xs[0]]+=[seperator.join(xs[1:])]
if xterm_titles:
if short_msg == None:
short_msg = mystr
- if "HOSTNAME" in os.environ.keys():
+ if "HOSTNAME" in os.environ:
short_msg = os.environ["HOSTNAME"]+": "+short_msg
xtermTitle(short_msg)
try:
if self.searchre.search(full_desc):
self.matches["desc"].append([full_package,masked])
self.mlen=0
- for mtype in self.matches.keys():
+ for mtype in self.matches:
self.matches[mtype].sort()
self.mlen += len(self.matches[mtype])
print "\b\b \n[ Results for search key : "+white(self.searchkey)+" ]"
print "[ Applications found : "+white(str(self.mlen))+" ]"
print " "
- for mtype in self.matches.keys():
+ for mtype in self.matches:
for match,masked in self.matches[mtype]:
if mtype=="pkg":
catpack=match
mylist = getlist(self.settings, "system")
worlddict=genericdict(worldlist)
- for x in worlddict.keys():
+ for x in worlddict:
if not portage.isvalidatom(x):
world_problems = True
continue
if myfilesdict is None:
myfilesdict="[empty/missing/bad digest]"
else:
- for myfetchfile in myfilesdict.keys():
+ for myfetchfile in myfilesdict:
if myfetchfile not in myfetchlist:
mysize+=myfilesdict[myfetchfile]
myfetchlist.append(myfetchfile)
if not slotmap.has_key(myslot):
slotmap[myslot]={}
slotmap[myslot][localtree.dbapi.cpv_counter(mypkg)]=mypkg
- for myslot in slotmap.keys():
+ for myslot in slotmap:
counterkeys=slotmap[myslot].keys()
counterkeys.sort()
if not counterkeys:
finally:
if vdb_lock:
portage.locks.unlockdir(vdb_lock)
- for x in pkgmap.keys():
+ for x in pkgmap:
for y in localtree.dep_match(x):
if y not in pkgmap[x]["omitted"] and \
y not in pkgmap[x]["selected"] and \
if not autoclean:
countdown(int(settings["CLEAN_DELAY"]), ">>> Unmerging")
- for x in pkgmap.keys():
+ for x in pkgmap:
for y in pkgmap[x]["selected"]:
print ">>> Unmerging "+y+"..."
emergelog(xterm_titles, "=== Unmerging... ("+y+")")
if vardbapi.plib_registry.hasEntries():
print colorize("WARN", "!!!") + " existing preserved libs:"
plibdata = vardbapi.plib_registry.getPreservedLibs()
- for cpv in plibdata.keys():
+ for cpv in plibdata:
print colorize("WARN", ">>>") + " package: %s" % cpv
for f in plibdata[cpv]:
print colorize("WARN", " * ") + " - %s" % f
else:
mydepgraph.display(
mydepgraph.altlist(reversed=("--tree" in myopts)))
- if ("--buildpkgonly" in myopts):
- if not mydepgraph.digraph.hasallzeros(ignore_priority=DepPriority.MEDIUM):
- print "\n!!! --buildpkgonly requires all dependencies to be merged."
- print "!!! You have to merge the dependencies before you can build this package.\n"
- sys.exit(1)
+ if "--buildpkgonly" in myopts and \
+ not mydepgraph.digraph.hasallzeros(ignore_priority=DepPriority.MEDIUM):
+ print "\n!!! --buildpkgonly requires all dependencies to be merged."
+ print "!!! You have to merge the dependencies before you can build this package.\n"
+ sys.exit(1)
else:
if ("--buildpkgonly" in myopts):
if not mydepgraph.digraph.hasallzeros(ignore_priority=DepPriority.MEDIUM):
xterm_titles = "notitles" not in settings.features
tmpcmdline = []
- if "--ignore-default-opts" not in sys.argv:
+ if "--ignore-default-opts" not in myopts:
tmpcmdline.extend(settings["EMERGE_DEFAULT_OPTS"].split())
tmpcmdline.extend(sys.argv[1:])
myaction, myopts, myfiles = parse_opts(tmpcmdline)
def load_infodir(self,infodir):
self.modifying()
- if self.configdict.has_key("pkg"):
- for x in self.configdict["pkg"].keys():
- del self.configdict["pkg"][x]
+ if "pkg" in self.configdict:
+ self.configdict["pkg"].clear()
else:
writemsg("No pkg setup for settings instance?\n",
noiselevel=-1)
return self.virts_p
virts = self.getvirtuals(myroot)
if virts:
- myvkeys = virts.keys()
- for x in myvkeys:
+ for x in virts:
vkeysplit = x.split("/")
if not self.virts_p.has_key(vkeysplit[1]):
self.virts_p[vkeysplit[1]] = virts[x]
return match
def has_key(self,mykey):
- for x in self.lookuplist:
- if x.has_key(mykey):
- return 1
- return 0
+ return mykey in self
def __contains__(self, mykey):
"""Called to implement membership test operators (in and not in)."""
- return bool(self.has_key(mykey))
+ for d in self.lookuplist:
+ if mykey in d:
+ return True
+ return False
def setdefault(self, k, x=None):
if k in self:
return x
def keys(self):
- return unique_array(flatten([x.keys() for x in self.lookuplist]))
+ return list(self)
+
+ def __iter__(self):
+ keys = set()
+ for d in self.lookuplist:
+ for k in d:
+ if k in keys:
+ continue
+ keys.add(k)
+ yield k
def __setitem__(self,mykey,myvalue):
"set a value; will be thrown away at reset() time"
def environ(self):
"return our locally-maintained environment"
mydict={}
- for x in self.keys():
+ for x in self:
myvalue = self[x]
if not isinstance(myvalue, basestring):
writemsg("!!! Non-string value in config: %s=%s\n" % \
(not droppriv and "sandbox" not in features and \
"usersandbox" not in features))
- if free:
+ if free or "SANDBOX_ACTIVE" in os.environ:
keywords["opt_name"] += " bash"
spawn_func = portage.process.spawn_bash
else:
noiselevel=-1)
return 0
del distlocks_subdir
- for myfile in filedict.keys():
+ for myfile in filedict:
"""
fetched status
0 nonexistent
else:
eout = portage.output.EOutput()
eout.quiet = mysettings.get("PORTAGE_QUIET", None) == "1"
- for x_key in mydigests[myfile].keys():
+ for x_key in mydigests[myfile]:
eout.ebegin("%s %s ;-)" % (myfile, x_key))
eout.eend(0)
fetched=2
def spawnebuild(mydo,actionmap,mysettings,debug,alwaysdep=0,logfile=None):
if alwaysdep or "noauto" not in mysettings.features:
# process dependency first
- if "dep" in actionmap[mydo].keys():
+ if "dep" in actionmap[mydo]:
retval=spawnebuild(actionmap[mydo]["dep"],actionmap,mysettings,debug,alwaysdep=alwaysdep,logfile=logfile)
if retval:
return retval
# merge the deps in so we have again a 'full' actionmap
# be glad when this can die.
- for x in actionmap.keys():
+ for x in actionmap:
if len(actionmap_deps.get(x, [])):
actionmap[x]["dep"] = ' '.join(actionmap_deps[x])
- if mydo in actionmap.keys():
+ if mydo in actionmap:
retval = spawnebuild(mydo,
actionmap, mysettings, debug, logfile=logfile)
elif mydo=="qmerge":
"""Returns the complete fetch list for a given package."""
return self.portdb.getfetchlist(pkg_key, mysettings=self.settings,
all=True, mytree=self.mytree)[1]
+ def __contains__(self):
+ return pkg_key in self.keys()
def has_key(self, pkg_key):
"""Returns true if the given package exists within pkgdir."""
- return pkg_key in self.keys()
+ return pkg_key in self
def keys(self):
"""Returns keys for all packages within pkgdir"""
return self.portdb.cp_list(self.cp, mytree=self.mytree)
if key not in self.__known_keys:
raise InvalidRestriction(key, match, "Key isn't valid")
- for cpv in self.keys():
+ for cpv in self.iterkeys():
cont = True
vals = self[cpv]
for key, match in restricts.iteritems():
else:
noise=verbose_instance
- dead_nodes = {}
- dead_nodes = dict.fromkeys(trg_cache.keys())
+ dead_nodes = set(trg_cache.iterkeys())
count=0
if not trg_cache.autocommits:
for x in valid_nodes_iterable:
# print "processing x=",x
count+=1
- if dead_nodes.has_key(x):
- del dead_nodes[x]
+ dead_nodes.discard(x)
try: entry = src_cache[x]
except KeyError, e:
noise.missing_entry(x)
except cache_errors.CacheError, ce:
noise.exception(ce)
del ce
- dead_nodes.clear()
noise.finish()
def perform_all(x, calc_prelink=0):
mydict = {}
- for k in hashfunc_map.keys():
+ for k in hashfunc_map:
mydict[k] = perform_checksum(x, hashfunc_map[k], calc_prelink)[0]
return mydict
got = " ".join(got)
return False, ("Insufficient data for checksum verification", got, expected)
- for x in mydict.keys():
+ for x in mydict:
if x == "size":
continue
- elif x in hashfunc_map.keys():
+ elif x in hashfunc_map:
myhash = perform_checksum(filename, x, calc_prelink=calc_prelink)[0]
if mydict[x] != myhash:
if strict:
if basedir and basedir[-1]!="/":
basedir=basedir+"/"
mylist=[]
- for myfile in entries["files"].keys():
+ for myfile in entries["files"]:
if "cvs" in entries["files"][myfile]["status"]:
if "0" == entries["files"][myfile]["revision"]:
mylist.append(basedir+myfile)
if recursive:
- for mydir in entries["dirs"].keys():
+ for mydir in entries["dirs"]:
mylist+=findnew(entries["dirs"][mydir],recursive,basedir+mydir)
return mylist
if basedir and basedir[-1]!="/":
basedir=basedir+"/"
mylist=[]
- for myfile in entries["files"].keys():
+ for myfile in entries["files"]:
if "cvs" in entries["files"][myfile]["status"]:
if "current" not in entries["files"][myfile]["status"]:
if "exists" in entries["files"][myfile]["status"]:
if entries["files"][myfile]["revision"]!="0":
mylist.append(basedir+myfile)
if recursive:
- for mydir in entries["dirs"].keys():
+ for mydir in entries["dirs"]:
mylist+=findchanged(entries["dirs"][mydir],recursive,basedir+mydir)
return mylist
if basedir and basedir[-1]!="/":
basedir=basedir+"/"
mylist=[]
- for myfile in entries["files"].keys():
+ for myfile in entries["files"]:
if "cvs" in entries["files"][myfile]["status"]:
if "exists" not in entries["files"][myfile]["status"]:
if "removed" not in entries["files"][myfile]["status"]:
mylist.append(basedir+myfile)
if recursive:
- for mydir in entries["dirs"].keys():
+ for mydir in entries["dirs"]:
mylist+=findmissing(entries["dirs"][mydir],recursive,basedir+mydir)
return mylist
mylist=[]
#ignore what cvs ignores.
- for myfile in entries["files"].keys():
+ for myfile in entries["files"]:
if "cvs" not in entries["files"][myfile]["status"]:
mylist.append(basedir+myfile)
if recursive:
- for mydir in entries["dirs"].keys():
+ for mydir in entries["dirs"]:
mylist+=findunadded(entries["dirs"][mydir],recursive,basedir+mydir)
return mylist
if basedir and basedir[-1]!="/":
basedir=basedir+"/"
mylist=[]
- for myfile in entries["files"].keys():
+ for myfile in entries["files"]:
if "removed" in entries["files"][myfile]["status"]:
mylist.append(basedir+myfile)
if recursive:
- for mydir in entries["dirs"].keys():
+ for mydir in entries["dirs"]:
mylist+=findremoved(entries["dirs"][mydir],recursive,basedir+mydir)
return mylist
# since it will provide no benefit due to the need to read CATEGORY
# from xpak.
if update_pkgindex and os.access(self.pkgdir, os.W_OK):
- cpv_all = self._pkg_paths.keys()
- stale = set(metadata).difference(cpv_all)
+ stale = [cpv for cpv in metadata if cpv not in self._pkg_paths]
for cpv in stale:
del metadata[cpv]
from portage.util import atomic_ofstream
if not hasattr(self, "auxdb"):
# unhandled exception thrown from constructor
return
- for x in self.auxdb.keys():
+ for x in self.auxdb:
self.auxdb[x].sync()
self.auxdb.clear()
repository ID's
TreeMap = {id: path}
"""
- return [k for k in self.treemap.keys() if k]
+ return [k for k in self.treemap if k]
def findname2(self, mycpv, mytree=None):
"""
returnme = []
for x in mylist:
if x == "INHERITED":
- returnme.append(' '.join(mydata.get("_eclasses_", {}).keys()))
+ returnme.append(' '.join(mydata.get("_eclasses_", [])))
else:
returnme.append(mydata.get(x,""))
def hasEntries(self):
""" Check if this registry contains any records. """
- return (len(self._data.keys()) > 0)
+ return len(self._data) > 0
def getPreservedLibs(self):
""" Return a mapping of packages->preserved objects.
@rtype Dict cpv->list-of-paths
"""
rValue = {}
- for cps in self._data.keys():
+ for cps in self._data:
rValue[self._data[cps][0]] = self._data[cps][2]
return rValue
else:
obj_dict[lib].append(mysplit[0])
mapfile = open(self._filename, "w")
- for lib in obj_dict.keys():
+ for lib in obj_dict:
mapfile.write(lib+" "+",".join(obj_dict[lib])+"\n")
mapfile.close()
# get list of libraries from old package instance
old_contents = self._installed_instance.getcontents().keys()
- old_libs = set([os.path.basename(x) for x in old_contents]).intersection(libmap.keys())
+ old_libs = set([os.path.basename(x) for x in old_contents]).intersection(libmap)
# get list of libraries from new package instance
- mylibs = set([os.path.basename(x) for x in mycontents]).intersection(libmap.keys())
+ mylibs = set([os.path.basename(x) for x in mycontents]).intersection(libmap)
# check which libs are present in the old, but not the new package instance
preserve_libs = old_libs.difference(mylibs)
for dblnk in installed_instances:
file_paths.update(dblnk.getcontents())
inode_map = {}
+ real_paths = set()
for path in file_paths:
try:
s = os.lstat(path)
raise
del e
continue
- if stat.S_ISREG(s.st_mode) and \
- s.st_nlink > 1 and \
+ if not stat.S_ISREG(s.st_mode):
+ continue
+ path = os.path.realpath(path)
+ if path in real_paths:
+ continue
+ real_paths.add(path)
+ if s.st_nlink > 1 and \
s.st_mode & (stat.S_ISUID | stat.S_ISGID):
k = (s.st_dev, s.st_ino)
inode_map.setdefault(k, []).append((path, s))
def cp_all(self):
returnme=[]
- for x in self.cpdict.keys():
+ for x in self.cpdict:
returnme.extend(self.cpdict[x])
return returnme
def _merge_logentries(a, b):
rValue = {}
- phases = set(a.keys()+b.keys())
+ phases = set(a)
+ phases.update(b)
for p in phases:
rValue[p] = []
if a.has_key(p):
my_elog_classes = set(mysettings.get("PORTAGE_ELOG_CLASSES", "").split())
- for key in all_logentries.keys():
+ for key in all_logentries:
default_logentries = filter_loglevels(all_logentries[key], my_elog_classes)
# in case the filters matched all messages and no module overrides exist
# remove unwanted entries from all logentries
rValue = {}
loglevels = map(str.upper, loglevels)
- for phase in logentries.keys():
+ for phase in logentries:
for msgtype, msgcontent in logentries[phase]:
if msgtype.upper() in loglevels or "*" in loglevels:
if not rValue.has_key(phase):
return _elog
import sys
-for f in _functions.keys():
+for f in _functions:
setattr(sys.modules[__name__], f, _make_msgfunction(_functions[f][0], _functions[f][1]))
del f, _functions
def process(mysettings, key, logentries, fulltext):
elogfilename = portage.elog_modules.mod_save.process(mysettings, key, logentries, fulltext)
- if (not "PORTAGE_ELOG_COMMAND" in mysettings.keys()) \
- or len(mysettings["PORTAGE_ELOG_COMMAND"]) == 0:
+ if not mysettings.get("PORTAGE_ELOG_COMMAND"):
raise portage.exception.MissingParameter("!!! Custom logging requested but PORTAGE_ELOG_COMMAND is not defined")
else:
mylogcmd = mysettings["PORTAGE_ELOG_COMMAND"]
def finalize(mysettings):
printer = EOutput()
- for key in _items.keys():
+ for key in _items:
print
printer.einfo("Messages for package %s:" % key)
print
mybody = "elog messages for the following packages generated by " + \
"process %d on host %s:\n" % (os.getpid(), socket.getfqdn())
- for key in _items.keys():
+ for key in _items:
mybody += "- %s\n" % key
mymessage = portage.mail.create_message(myfrom, myrecipient, mysubject, mybody, attachments=_items.values())
self.data, self.errors = self._loader.load()
+ def __iter__(self):
+ return iter(self.data)
+
class PackageKeywordsFile(UserConfigKlass):
"""
Inherits from UserConfigKlass; implements a file-based backend.
for x in tbz2list:
x = os.path.basename(x)
binpkg_filenames.add(x)
- if ((not metadata[baseurl]["data"].has_key(x)) or \
- (x not in metadata[baseurl]["data"].keys())):
+ if x not in metadata[baseurl]["data"]:
sys.stderr.write(yellow("x"))
metadata[baseurl]["modified"] = 1
myid = None
results.append("Found %(count)s locks" % {"count":mycount})
- for x in mylist.keys():
+ for x in mylist:
if mylist[x].has_key(myhost) or remove_all_locks:
mylockname = hardlock_name(path+"/"+x)
if hardlink_is_mine(mylockname, path+"/"+x) or \
not os.path.exists(path+"/"+x) or \
remove_all_locks:
- for y in mylist[x].keys():
+ for y in mylist[x]:
for z in mylist[x][y]:
filename = path+"/"+x+".hardlock-"+y+"-"+z
if filename == mylockname:
class Manifest1Entry(ManifestEntry):
def __str__(self):
- myhashkeys = self.hashes.keys()
- for hashkey in myhashkeys:
+ for hashkey in self.hashes:
if hashkey != "size":
break
hashvalue = self.hashes[hashkey]
pass
def checkIntegrity(self):
- for t in self.fhashdict.keys():
+ for t in self.fhashdict:
for f in self.fhashdict[t]:
- if not portage.const.MANIFEST2_REQUIRED_HASH in self.fhashdict[t][f].keys():
+ if portage.const.MANIFEST2_REQUIRED_HASH not in self.fhashdict[t][f]:
raise MissingParameter("Missing %s checksum: %s %s" % (portage.const.MANIFEST2_REQUIRED_HASH, t, f))
def write(self, sign=False, force=False):
try:
f = PackageMaskFile(self.fname)
f.load()
- [atom for atom in f.keys() if self.assertTrue(atom in self.atoms)]
+ for atom in f:
+ self.assertTrue(atom in self.atoms)
finally:
self.NukeFile()
def testPortageModulesFile(self):
self.BuildFile()
f = PortageModulesFile(self.fname)
- for k in f.keys():
+ for k in f:
self.assertEqual( f[k], self.items[k] )
self.NukeFile()
def testVarExpandPass(self):
varDict = { "a":"5", "b":"7", "c":"-5" }
- for key in varDict.keys():
+ for key in varDict:
result = varexpand( "$%s" % key, varDict )
self.failIf( result != varDict[key],
"""Performs a function on each value of each key in a dictlist.
Returns a new dictlist."""
new_dl = {}
- for key in myDict.keys():
+ for key in myDict:
new_dl[key] = []
new_dl[key] = map(func,myDict[key])
return new_dl
for mydict in original_dicts:
if mydict is None:
continue
- for y in mydict.keys():
+ for y in mydict:
if not y in final_dict:
final_dict[y] = []
for x in mydict.values():
myfile.write(x+"\n")
else:
- for x in mydict.keys():
+ for x in mydict:
myfile.write("%s %s\n" % (x, " ".join(mydict[x])))
myfile.close()
except IOError: