summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-07-01 12:48:57 +0000
committerZac Medico <zmedico@gentoo.org>2008-07-01 12:48:57 +0000
commit5495f72f0c8202728636eb9bdac74ce5009b0d5a (patch)
treef8b6663bcfc5b213b4df9e73a3d1b5928dfa96c4
parentff5c09fb29db5910308628aa06d2ffe368c7264a (diff)
downloadportage-5495f72f0c8202728636eb9bdac74ce5009b0d5a.tar.gz
portage-5495f72f0c8202728636eb9bdac74ce5009b0d5a.tar.bz2
portage-5495f72f0c8202728636eb9bdac74ce5009b0d5a.zip
Py3k compatibility patch #3 by Ali Polatel <hawking@g.o>.
Replace dict.has_key() calls with "in" and "not in" operators. svn path=/main/trunk/; revision=10872
-rw-r--r--pym/portage/dbapi/__init__.py2
-rw-r--r--pym/portage/dbapi/bintree.py2
-rw-r--r--pym/portage/dbapi/vartree.py17
-rw-r--r--pym/portage/dbapi/virtual.py8
4 files changed, 15 insertions, 14 deletions
diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py
index 54ce7afc3..0900fcfa8 100644
--- a/pym/portage/dbapi/__init__.py
+++ b/pym/portage/dbapi/__init__.py
@@ -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:
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 83e37c059..22f91ceef 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -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)
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 1b13b8bc9..095d29901 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -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
diff --git a/pym/portage/dbapi/virtual.py b/pym/portage/dbapi/virtual.py
index 444b5363a..bf90f305b 100644
--- a/pym/portage/dbapi/virtual.py
+++ b/pym/portage/dbapi/virtual.py
@@ -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)