FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Portage Developer

 
 
LinkBack Thread Tools
 
Old 07-01-2008, 11:26 AM
Ali Polatel
 
Default Replace has_key() with the in operator (portage.dbapi)

---
pym/portage/dbapi/__init__.py | 2 +-
pym/portage/dbapi/bintree.py | 2 +-
pym/portage/dbapi/vartree.py | 16 ++++++++--------
pym/portage/dbapi/virtual.py | 8 ++++----
4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.py
index ba37c86..510999a 100644
--- a/pym/portage/dbapi/__init__.py
+++ b/pym/portage/dbapi/__init__.py
@@ -167,7 +167,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
" % mypath, 1)
unlockfile((mypath, None, None))
else:
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index f795d98..9e2ea5a 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -693,7 +693,7 @@ class binarytree(object):
#writemsg(green(" -- DONE!

"))

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+"
",
noiselevel=-1)
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index 8b4093a..65cb5c3 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -82,7 +82,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:
@@ -596,7 +596,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][:]
@@ -624,7 +624,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

@@ -720,7 +720,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,
@@ -730,11 +730,11 @@ 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 not 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
@@ -1266,7 +1266,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]
@@ -2687,7 +2687,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 444b536..bf90f30 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)
--
1.5.6.1

--
gentoo-portage-dev@lists.gentoo.org mailing list
 

Thread Tools




All times are GMT. The time now is 07:13 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org