Py3k compatibility patch #3 by Ali Polatel <hawking@g.o>.
authorZac Medico <zmedico@gentoo.org>
Tue, 1 Jul 2008 12:48:57 +0000 (12:48 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 1 Jul 2008 12:48:57 +0000 (12:48 -0000)
Replace dict.has_key() calls with "in" and "not in" operators.

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

pym/portage/dbapi/__init__.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/vartree.py
pym/portage/dbapi/virtual.py

index 54ce7afc328955dfb147652d66f288b37d065042..0900fcfa8013a430d3567e6afb3764ea8c54f2fe 100644 (file)
@@ -173,7 +173,7 @@ class dbapi(object):
 
        def invalidentry(self, mypath):
                if mypath.endswith('portage_lockfile'):
-                       if not os.environ.has_key("PORTAGE_MASTER_PID"):
+                       if "PORTAGE_MASTER_PID" not in os.environ:
                                writemsg("Lockfile removed: %s\n" % mypath, 1)
                                unlockfile((mypath, None, None))
                        else:
index 83e37c05921c3faeab950676222f67dc39f28aff..22f91ceefb6de7aad9f00155a121e809d67002f2 100644 (file)
@@ -696,7 +696,7 @@ class binarytree(object):
                        #writemsg(green("  -- DONE!\n\n"))
 
                        for mypkg in self.remotepkgs.keys():
-                               if not self.remotepkgs[mypkg].has_key("CATEGORY"):
+                               if "CATEGORY" not in self.remotepkgs[mypkg]:
                                        #old-style or corrupt package
                                        writemsg("!!! Invalid remote binary package: "+mypkg+"\n",
                                                noiselevel=-1)
index 1b13b8bc9a6f931e1b5e8573d468c6fca7eda697..095d299012c4710a4483f1f12079997ca04bf0e2 100644 (file)
@@ -89,7 +89,7 @@ class PreservedLibsRegistry(object):
                """
                cp = "/".join(catpkgsplit(cpv)[:2])
                cps = cp+":"+slot
-               if len(paths) == 0 and self._data.has_key(cps) \
+               if len(paths) == 0 and cps in self._data \
                                and self._data[cps][0] == cpv and int(self._data[cps][1]) == int(counter):
                        del self._data[cps]
                elif len(paths) > 0:
@@ -463,7 +463,7 @@ class vardbapi(dbapi):
                        mystat = os.stat(self.getpath(mysplit[0]))[stat.ST_MTIME]
                except OSError:
                        mystat = 0
-               if use_cache and self.cpcache.has_key(mycp):
+               if use_cache and mycp in self.cpcache:
                        cpc = self.cpcache[mycp]
                        if cpc[0] == mystat:
                                return cpc[1][:]
@@ -491,7 +491,7 @@ class vardbapi(dbapi):
                self._cpv_sort_ascending(returnme)
                if use_cache:
                        self.cpcache[mycp] = [mystat, returnme[:]]
-               elif self.cpcache.has_key(mycp):
+               elif mycp in self.cpcache:
                        del self.cpcache[mycp]
                return returnme
 
@@ -587,7 +587,7 @@ class vardbapi(dbapi):
                mykey = dep_getkey(mydep)
                mycat = catsplit(mykey)[0]
                if not use_cache:
-                       if self.matchcache.has_key(mycat):
+                       if mycat in self.matchcache:
                                del self.mtdircache[mycat]
                                del self.matchcache[mycat]
                        return list(self._iter_match(mydep,
@@ -597,11 +597,12 @@ class vardbapi(dbapi):
                except (IOError, OSError):
                        curmtime=0
 
-               if not self.matchcache.has_key(mycat) or not self.mtdircache[mycat]==curmtime:
+               if mycat not in self.matchcache or \
+                       self.mtdircache[mycat] != curmtime:
                        # clear cache entry
                        self.mtdircache[mycat] = curmtime
                        self.matchcache[mycat] = {}
-               if not self.matchcache[mycat].has_key(mydep):
+               if mydep not in self.matchcache[mycat]:
                        mymatch = list(self._iter_match(mydep,
                                self.cp_list(mydep.cp, use_cache=use_cache)))
                        self.matchcache[mycat][mydep] = mymatch
@@ -1162,7 +1163,7 @@ class vartree(object):
                myprovides = {}
                for node in self.getallcpv():
                        for mykey in self.get_provide(node):
-                               if myprovides.has_key(mykey):
+                               if mykey in myprovides:
                                        myprovides[mykey] += [node]
                                else:
                                        myprovides[mykey] = [node]
@@ -2593,7 +2594,7 @@ class dblink(object):
                #if we have a file containing previously-merged config file md5sums, grab it.
                conf_mem_file = os.path.join(destroot, CONFIG_MEMORY_FILE)
                cfgfiledict = grabdict(conf_mem_file)
-               if self.settings.has_key("NOCONFMEM"):
+               if "NOCONFMEM" in self.settings:
                        cfgfiledict["IGNORE"]=1
                else:
                        cfgfiledict["IGNORE"]=0
index 444b5363a0e0c3ef91d707b12c11166a2ce5d4a8..bf90f305bfcd3c144693a741e12a4c3e901159df 100644 (file)
@@ -40,7 +40,7 @@ class fakedbapi(dbapi):
                return result[:]
 
        def cpv_exists(self, mycpv):
-               return self.cpvdict.has_key(mycpv)
+               return mycpv in self.cpvdict
 
        def cp_list(self, mycp, use_cache=1):
                cachelist = self._match_cache.get(mycp)
@@ -94,9 +94,9 @@ class fakedbapi(dbapi):
                """Removes a cpv from the list of available packages."""
                self._clear_cache()
                mycp = cpv_getkey(mycpv)
-               if self.cpvdict.has_key(mycpv):
+               if mycpv in self.cpvdict:
                        del     self.cpvdict[mycpv]
-               if not self.cpdict.has_key(mycp):
+               if mycp not in self.cpdict:
                        return
                while mycpv in self.cpdict[mycp]:
                        del self.cpdict[mycp][self.cpdict[mycp].index(mycpv)]
@@ -129,4 +129,4 @@ class testdbapi(object):
                fake_api = dir(dbapi)
                for call in fake_api:
                        if not hasattr(self, call):
-                               setattr(self, call, f)
\ No newline at end of file
+                               setattr(self, call, f)