Merged from trunk -r14378:14388
authorFabian Groffen <grobian@gentoo.org>
Thu, 24 Sep 2009 17:25:35 +0000 (17:25 -0000)
committerFabian Groffen <grobian@gentoo.org>
Thu, 24 Sep 2009 17:25:35 +0000 (17:25 -0000)
   | 14379   | Replace doct.keys() usage with __iter__(), since it behaves  |
   | zmedico | identically in both python 2.x and 3.x.                      |

   | 14380   | Replace dict.keys() usage with __iter__(), since it behaves  |
   | zmedico | identically in both python 2.x and 3.x.                      |

   | 14381   | Fix for python 3.x compatibility.                            |
   | zmedico |                                                              |

   | 14382   | Replace dict.keys() usage with __iter__(), since it behaves  |
   | zmedico | identically in both python 2.x and 3.x.                      |

   | 14383   | Remove code that's been commented out.                       |
   | zmedico |                                                              |

   | 14384   | Replace dict.keys() usage with __iter__(), since it behaves  |
   | zmedico | identically in both python 2.x and 3.x.                      |

   | 14385   | Replace dict.keys() usage with __iter__(), since it behaves  |
   | zmedico | identically in both python 2.x and 3.x.                      |

   | 14386   | Disable the ignore_none parameter for stack_dicts() since    |
   | zmedico | having it return None instead of a dict sometimes is         |
   |         | hazardous.                                                   |

   | 14387   | Clean up stack_dicts() a little.                             |
   | zmedico |                                                              |

   | 14388   | Don't pass the ignore_none parameter to stack_dicts() since  |
   | zmedico | it does nothing now.                                         |

svn path=/main/branches/prefix/; revision=14405

27 files changed:
bin/egencache
bin/emaint
bin/glsa-check
bin/repoman
pym/_emerge/MetadataRegen.py
pym/_emerge/PollSelectAdapter.py
pym/_emerge/actions.py
pym/_emerge/unmerge.py
pym/portage/__init__.py
pym/portage/cache/anydbm.py
pym/portage/cache/mappings.py
pym/portage/cache/template.py
pym/portage/checksum.py
pym/portage/cvstree.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
pym/portage/getbinpkg.py
pym/portage/glsa.py
pym/portage/manifest.py
pym/portage/sets/base.py
pym/portage/sets/dbapi.py
pym/portage/sets/files.py
pym/portage/util.py

index 79b12dc7adf54980e515f2ba4ca1222ef084750b..47f93c792755d6e0db6691dffe997a246f4adbd0 100755 (executable)
@@ -204,7 +204,7 @@ class GenCache(object):
                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
@@ -224,7 +224,7 @@ class GenCache(object):
                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
index 3279bc32110cf5863187e8eb3c0c647fa4bce0cd..76257eb2c05ac44b6810d791f439f3811b8674d7 100755 (executable)
@@ -477,7 +477,7 @@ def emaint_main(myargv):
                "cleanresume":CleanResume
        }
 
-       module_names = list(modules.keys())
+       module_names = list(modules)
        module_names.sort()
        module_names.insert(0, "all")
 
index 0bcecc0921b3968d0cf9b1de228f1d8e90b5be05..14258823c278e7bbcf71d115c0e5f50850d7e057 100755 (executable)
@@ -174,12 +174,12 @@ def summarylist(myglsalist, fd1=sys.stdout, fd2=sys.stderr):
 
                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))
index 715f5649acba2f806d1adb9c2e6aef93a5673666..de78f903b9863a9b4173e9b1fd3478b6af00346b 100755 (executable)
@@ -151,7 +151,7 @@ def ParseArgs(args, qahelp):
                '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]")
@@ -196,7 +196,7 @@ def ParseArgs(args, qahelp):
        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"))
@@ -206,7 +206,7 @@ def ParseArgs(args, qahelp):
 
        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]))
@@ -328,7 +328,7 @@ qahelp={
        "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((
index 6bfd722c262cd250cba474463e673689359d9425..287312e17944a56343a9919ec51fa13ece6b6c36 100644 (file)
@@ -89,7 +89,7 @@ class MetadataRegen(PollScheduler):
                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),
@@ -103,7 +103,7 @@ class MetadataRegen(PollScheduler):
                        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 " + \
index 7b7d3d95ad51c39b7c4afe96e07e559ad5d0ddb8..b136e7eb03a9b7482bd101eef731ba18254eaa85 100644 (file)
@@ -48,7 +48,7 @@ class PollSelectAdapter(PollConstants):
 
                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[:]
index fcf0453c9c09ceef5e9cc6efab5357671fb018e7..31d85dd407da051ff48254600dd45733f65a3421 100644 (file)
@@ -1290,7 +1290,7 @@ def action_info(settings, trees, myopts, myfiles):
        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',
@@ -1650,7 +1650,7 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
 
        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),
index b97207d68b249aec02998f336e3a4afd4853830b..4d2a546c5b2915bb8a3d8ace3916d6d2ab73280b 100644 (file)
@@ -243,7 +243,7 @@ def unmerge(root_config, myopts, unmerge_action,
                                        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()
index 71c496b2900f22e4b9e1d94fa7b844f195e63c74..fe1acf30de1151f0949131abfeef51732652b2b5 100644 (file)
@@ -1894,7 +1894,7 @@ class config(object):
                                        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)
@@ -2635,7 +2635,7 @@ class config(object):
                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:
@@ -2665,7 +2665,7 @@ class config(object):
                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:
@@ -2818,7 +2818,7 @@ class config(object):
                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:
@@ -2841,7 +2841,7 @@ class config(object):
                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:
@@ -3026,7 +3026,7 @@ class config(object):
                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(
@@ -3107,7 +3107,7 @@ class config(object):
                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(
@@ -4729,7 +4729,7 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks",
                                                                        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)))
@@ -5236,7 +5236,7 @@ def digestgen(myarchives, mysettings, overwrite=1, manifestonly=0, myportdb=None
                        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:
@@ -8455,9 +8455,9 @@ class FetchlistDict(portage.cache.mappings.Mapping):
                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
@@ -8864,7 +8864,7 @@ class MtimeDB(dict):
                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]
index 143c321e14c371914d5d75fa79d9fedfec7c54af..6add2da60c7c7448d9185f535bc0dc7edf8d17f2 100644 (file)
@@ -3,7 +3,11 @@
 # 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:
@@ -31,8 +35,10 @@ class database(fs_template.FsBased):
                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:
@@ -44,8 +50,10 @@ class database(fs_template.FsBased):
                        # 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)
index b777ed1d00af30bd197a85000ebf51bad0cc36fd..a6c111897261d3b826bbf6a5173843c1c4085bbc 100644 (file)
@@ -226,9 +226,9 @@ class ProtectedDict(MutableMapping):
                        
 
        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
 
index 9e779520b3422c417503d7d03df03bfa5f33e994..3b003b1f674f281fba250a6baaebc10b6940bb26 100644 (file)
@@ -68,8 +68,8 @@ class database(object):
                        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_"])
@@ -110,13 +110,13 @@ class database(object):
                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):
@@ -182,7 +182,7 @@ class database(object):
                        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():
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 87724adf1870c5ee8b765f2361b523e61ceb75fb..da8b40e15242c67417d17fc2455214fe3c90b46a 100644 (file)
@@ -235,9 +235,6 @@ def getentries(mydir,recursive=0):
                                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:
@@ -315,18 +312,3 @@ def getentries(mydir,recursive=0):
                        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(
-                       
-               
index cd3f3470e9d95fc48b431a08986d594908891376..0f1de429ae633c78eb621d6050c074703b443501 100644 (file)
@@ -786,7 +786,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 5d88f5b9939c3052956eaf836ae37104e9bd6ee2..24e93dc204c41baa373bcdb5b3b9e8ae44b3d4e7 100644 (file)
@@ -154,7 +154,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)))]
@@ -1736,7 +1736,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
@@ -1809,7 +1809,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"]
@@ -3076,7 +3076,7 @@ class dblink(object):
 
                if pkgfiles:
                        self.updateprotect()
-                       mykeys = list(pkgfiles.keys())
+                       mykeys = list(pkgfiles)
                        mykeys.sort()
                        mykeys.reverse()
 
@@ -5160,7 +5160,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")
 
index 62e76b4f336b27f73edb09fdd71afefabe8bf524..47095afffaee356a841acc2d0f0191cac09adf2a 100644 (file)
@@ -818,7 +818,7 @@ class PackageIndex(object):
                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]])
@@ -835,7 +835,7 @@ class PackageIndex(object):
                                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]])
index 1f061b23108e8d22ffab013b6e7e2e2a7faba65a..4049efc2d7e6f18b6daafb4fdf6677c3bd744a81 100644 (file)
@@ -581,7 +581,7 @@ class Glsa:
                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"])
@@ -626,7 +626,7 @@ class Glsa:
                @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():
@@ -679,7 +679,7 @@ class Glsa:
                @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)
index 7b20a3c2d56160637fd652f30191102eb26c115a..cb81b893328ec0810e0ecfa746dee24be176f85c 100644 (file)
@@ -74,7 +74,7 @@ class ManifestEntry(object):
 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:
@@ -202,15 +202,15 @@ class Manifest(object):
                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:
index 0c08ee1948b1a5f9a572e13859f7027017c219f4..d58b5f297be960cfca6c1c0a76d685f1a7d76be5 100644 (file)
@@ -126,7 +126,7 @@ class PackageSet(object):
                                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
index 06ebcadfd6cde3f065d2c470be1bcb0b28a9c074..f2e7dd1106d9528fd0b8597c8b4e70e5c1bc727e 100644 (file)
@@ -132,7 +132,7 @@ class VariableSet(EverythingSet):
                        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,
index b0d13fbd56f861de15aa45d72bdefb9efcc4adbc..ba56e7b0f0482de4e2d497dc0ed6737a70e64fff 100644 (file)
@@ -83,7 +83,7 @@ class StaticFileSet(EditablePackageSet):
                                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),
@@ -92,7 +92,7 @@ class StaticFileSet(EditablePackageSet):
                                        # 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
                
@@ -182,7 +182,7 @@ class ConfigFileSet(PackageSet):
 
        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:
@@ -253,7 +253,7 @@ class WorldSet(EditablePackageSet):
                                        raise
                                del e
                                data = {}
-                       atoms = list(data.keys())
+                       atoms = list(data)
                        self._mtime = mtime
                        atoms_changed = True
                else:
@@ -273,7 +273,7 @@ class WorldSet(EditablePackageSet):
                                        raise
                                del e
                                data = {}
-                       nonatoms = list(data.keys())
+                       nonatoms = list(data)
                        self._mtime2 = mtime
                        atoms_changed = True
                else:
index 57a14c25f77a5b4f5fe07ea0745f37bec1bda7f6..bae33a05f45e2cb9d4972173d42fbe029a0a4955 100644 (file)
@@ -219,20 +219,15 @@ def stack_dicts(dicts, incremental=0, incrementals=[], ignore_none=0):
        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):
@@ -253,7 +248,7 @@ 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):
        """