Replace dict.keys() usage with __iter__(), since it behaves identically in
authorZac Medico <zmedico@gentoo.org>
Tue, 22 Sep 2009 21:26:20 +0000 (21:26 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 22 Sep 2009 21:26:20 +0000 (21:26 -0000)
both python 2.x and 3.x.

svn path=/main/trunk/; revision=14384

pym/portage/checksum.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/porttree.py
pym/portage/dbapi/vartree.py
pym/portage/dbapi/virtual.py
pym/portage/elog/__init__.py
pym/portage/elog/mod_mail.py

index 9cc2d82e773905b8d618017840690f47bbc5a244..6b849d5d7715fc8648fa8d0c57b5702021e29acc 100644 (file)
@@ -134,7 +134,7 @@ def perform_all(x, calc_prelink=0):
        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:
index 79a6e5401f175a2855b24a0994456c5140d3c8df..76447bf61899cbe1512bf5fe35704422ed51eb86 100644 (file)
@@ -783,7 +783,7 @@ class binarytree(object):
                                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,
index 7f20e66fd5d1eeaa4d4b0c49f5fe6ec523519936..b073e4268c18a1a43cfae370bd2b76930fc29bb0 100644 (file)
@@ -876,7 +876,7 @@ class portdbapi(dbapi):
                                                y == "CVS":
                                                continue
                                        d[x+"/"+y] = None
-               l = list(d.keys())
+               l = list(d)
                l.sort()
                return l
 
@@ -933,7 +933,7 @@ class portdbapi(dbapi):
                                (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)
index be69aab092573605ef89a80843f0a89123c24351..2bbc0f88aff45a9c823ee50d066d1da6f8ecf474 100644 (file)
@@ -153,7 +153,7 @@ class PreservedLibsRegistry(object):
 
                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)))]
@@ -1020,7 +1020,7 @@ class vardbapi(dbapi):
                                self.invalidentry(self.getpath(y))
                                continue
                        d[mysplit[0]+"/"+mysplit[1]] = None
-               return list(d.keys())
+               return list(d)
 
        def checkblockers(self, origdep):
                pass
@@ -1093,7 +1093,7 @@ class vardbapi(dbapi):
                        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"]
@@ -2360,7 +2360,7 @@ class dblink(object):
 
                if pkgfiles:
                        self.updateprotect()
-                       mykeys = list(pkgfiles.keys())
+                       mykeys = list(pkgfiles)
                        mykeys.sort()
                        mykeys.reverse()
 
@@ -4429,7 +4429,7 @@ def tar_contents(contents, root, tar, protect=None, onProgress=None):
        curval = 0
        if onProgress:
                onProgress(maxval, 0)
-       paths = list(contents.keys())
+       paths = list(contents)
        paths.sort()
        for path in paths:
                curval += 1
index 5d1e933a1aeb33c708be6165d61f66f1c90ead3b..6c567a0728e78294c26a239d999a958d20df171f 100644 (file)
@@ -59,7 +59,7 @@ class fakedbapi(dbapi):
                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
index 53c0a85f779ca032074081ab841ec65674598c98..15e8c9bcefc797181922293832d2509cee87a5ab 100644 (file)
@@ -100,7 +100,7 @@ def elog_process(cpv, mysettings, phasefilter=None):
        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:
index ac96f3b200a666b182eee8ea4995591407a0535d..96e45ba2129ea31b15c092152bd00ef972faba4a 100644 (file)
@@ -22,14 +22,14 @@ def process(mysettings, key, logentries, fulltext):
 
        # 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")