diff options
Diffstat (limited to 'pym/portage.py')
-rw-r--r-- | pym/portage.py | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/pym/portage.py b/pym/portage.py index ff016c021..1bd033011 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -1657,9 +1657,8 @@ class config: 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) @@ -2057,8 +2056,7 @@ class config: 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] @@ -2179,7 +2177,16 @@ class config: 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" @@ -2192,7 +2199,7 @@ class config: 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" % \ @@ -2529,7 +2536,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", noiselevel=-1) return 0 del distlocks_subdir - for myfile in filedict.keys(): + for myfile in filedict: """ fetched status 0 nonexistent @@ -2760,7 +2767,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", else: eout = 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 @@ -3016,7 +3023,7 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0): 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 @@ -3822,11 +3829,11 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, # 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: if mydo=="package": portage_util.ensure_dirs( os.path.join(mysettings["PKGDIR"], mysettings["CATEGORY"])) @@ -8064,9 +8071,11 @@ class FetchlistDict(UserDict.DictMixin): """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) |