public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Ali Polatel <hawking@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Subject: [gentoo-portage-dev] [PATCH 3/6] Replace has_key() with the in operator (portage.dbapi)
Date: Tue,  1 Jul 2008 14:26:51 +0300	[thread overview]
Message-ID: <1214911614-31263-3-git-send-email-hawking@gentoo.org> (raw)
In-Reply-To: <1214911614-31263-2-git-send-email-hawking@gentoo.org>

---
 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\n" % 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!\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 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



  reply	other threads:[~2008-07-01 11:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-01 11:26 [gentoo-portage-dev] [PATCH 1/6] Replace has_key() with the in operator (portage) Ali Polatel
2008-07-01 11:26 ` [gentoo-portage-dev] [PATCH 2/6] Replace has_key() with the in operator (portage.cache) Ali Polatel
2008-07-01 11:26   ` Ali Polatel [this message]
2008-07-01 11:26     ` [gentoo-portage-dev] [PATCH 4/6] Replace has_key() with the in operator (portage.elog) Ali Polatel
2008-07-01 11:26       ` [gentoo-portage-dev] [PATCH 5/6] Replace has_key() with the in operator (bin) Ali Polatel
2008-07-01 11:26         ` [gentoo-portage-dev] [PATCH 6/6] Add deprecation warnings to classes that have has_key() methods Ali Polatel
2008-07-01 12:09           ` [gentoo-portage-dev] " Ali Polatel
2008-07-01 18:35             ` Alec Warner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1214911614-31263-3-git-send-email-hawking@gentoo.org \
    --to=hawking@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox