Remove more unnecessary list generation.
authorZac Medico <zmedico@gentoo.org>
Thu, 21 Jun 2007 12:01:43 +0000 (12:01 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 21 Jun 2007 12:01:43 +0000 (12:01 -0000)
svn path=/main/trunk/; revision=6913

12 files changed:
pym/portage/elog/__init__.py
pym/portage/elog/filtering.py
pym/portage/elog/messages.py
pym/portage/elog/mod_custom.py
pym/portage/elog/mod_echo.py
pym/portage/elog/mod_mail_summary.py
pym/portage/getbinpkg.py
pym/portage/locks.py
pym/portage/manifest.py
pym/portage/tests/env/config/test_PackageMaskFile.py
pym/portage/tests/env/config/test_PortageModulesFile.py
pym/portage/tests/util/test_varExpand.py

index 77bdd1b944e85794edcf678db463ea4ccf41709a..5b8ac44c3aa92da2d67d810af8a8383d4641d47e 100644 (file)
@@ -15,7 +15,8 @@ import os
 
 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):
@@ -51,7 +52,7 @@ def elog_process(cpv, mysettings):
        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
index f4748fede646f986e92204ea4b55d5a888957712..e8a5430fd04cc09bd4e9ba81895d7dfc3bab5db1 100644 (file)
@@ -7,7 +7,7 @@ def filter_loglevels(logentries, loglevels):
        # 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):
index bfe428030dd50ccbb7a706e4a04ddffa512ad1b1..c2b21ac800f4bd6c6b04401aef0fd7dbf8ff918b 100644 (file)
@@ -84,6 +84,6 @@ def _make_msgfunction(level, color):
        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
index a486c8931e6b98542a8cf21a233d457bc0396bb7..09d981a0c05d85fa9946bd9d2047a8d1d9b9f2b3 100644 (file)
@@ -8,8 +8,7 @@ import portage.elog_modules.mod_save, portage.process, portage.exception
 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"]
index 125a8c40e2181b53a0aa2dcc269d16a27ab342d2..6dcc652338b4253193db3a1b871b53a2b10fcc4d 100644 (file)
@@ -12,7 +12,7 @@ def process(mysettings, key, logentries, fulltext):
 
 def finalize(mysettings):
        printer = EOutput()
-       for key in _items.keys():
+       for key in _items:
                print
                printer.einfo("Messages for package %s:" % key)
                print
index a8e6949354294f3b11be756a20f71532adf03265..0a39b17b13770d1fe72deb022a361a82593669a4 100644 (file)
@@ -31,7 +31,7 @@ def finalize(mysettings):
 
        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())
index f44f690a680c18e4e0db42dd3d068891f58c78c5..410a48577af3627f7aa2e0fbcf8eeff6aa2f5c01 100644 (file)
@@ -515,8 +515,7 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
        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
index 2575a978b5c245a92f0251caf95a34edc82e7ee4..19c7352b7d745053030fd671a60eddb908905342 100644 (file)
@@ -284,13 +284,13 @@ def hardlock_cleanup(path, remove_all_locks=False):
 
        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:
index cd03dc293d18218316bef6a371b7113edaeaa8f9..5add55c81ab5d62e987231c1e24f0f69f404545f 100644 (file)
@@ -79,8 +79,7 @@ class ManifestEntry(object):
 
 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]
@@ -345,9 +344,9 @@ class Manifest(object):
                                        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):
index ad87d5a56a15131411e19cc065454a84fc51c92e..e8357f7e61b2754e60df6d33ef59affa27866289 100644 (file)
@@ -18,7 +18,8 @@ class PackageMaskFileTestCase(TestCase):
                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()
        
index b523cbe7bf370ca32ca55f4b20fb9c252e9197b1..03104cff5f182a830fa6df52f435fab7f12165e1 100644 (file)
@@ -18,7 +18,7 @@ class PortageModulesFileTestCase(TestCase):
        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()
 
index ee0f573c97b1e656d80b0edd77b4c7feebf446c0..e4f85ef43d08f2c707b0156aefc681837284df72 100644 (file)
@@ -11,7 +11,7 @@ class VarExpandTestCase(TestCase):
        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],