Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Gentoo Portage Developer (http://www.linux-archive.org/gentoo-portage-developer/)
-   -   Replace has_key() with the in operator (portage.cache) (http://www.linux-archive.org/gentoo-portage-developer/116809-replace-has_key-operator-portage-cache.html)

Ali Polatel 07-01-2008 11:26 AM

Replace has_key() with the in operator (portage.cache)
 
---
pym/portage/cache/metadata_overlay.py | 2 +-
pym/portage/cache/sql_template.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/portage/cache/metadata_overlay.py b/pym/portage/cache/metadata_overlay.py
index 13d1278..e25759c 100644
--- a/pym/portage/cache/metadata_overlay.py
+++ b/pym/portage/cache/metadata_overlay.py
@@ -61,7 +61,7 @@ class database(template.database):

def _delitem(self, cpv):
value = self[cpv] # validates whiteout and/or raises a KeyError when necessary
- if self.db_ro.has_key(cpv):
+ if cpv in self.db_ro:
self.db_rw[cpv] = self._create_whiteout(value)
else:
del self.db_rw[cpv]
diff --git a/pym/portage/cache/sql_template.py b/pym/portage/cache/sql_template.py
index f32a728..3c5cbd4 100644
--- a/pym/portage/cache/sql_template.py
+++ b/pym/portage/cache/sql_template.py
@@ -150,7 +150,7 @@ class SQLDatabase(template.database):
# so we store only what's handed to us and is a known key
db_values = []
for key in self._known_keys:
- if values.has_key(key) and values[key] != ':
+ if key in values and values[key] != ':
db_values.append({"key":key, "value":values[key]})

if len(db_values) > 0:
--
1.5.6.1

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


All times are GMT. The time now is 10:21 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.