summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-07-01 12:55:49 +0000
committerZac Medico <zmedico@gentoo.org>2008-07-01 12:55:49 +0000
commit211b56614083fbb4f78b74f28a3962f97bf684d5 (patch)
tree9358a35593b08d5b140dcf9d5569b7ce7c7cab51
parent56aea2672000174743514bcc7f58f41733f64ce4 (diff)
downloadportage-211b56614083fbb4f78b74f28a3962f97bf684d5.tar.gz
portage-211b56614083fbb4f78b74f28a3962f97bf684d5.tar.bz2
portage-211b56614083fbb4f78b74f28a3962f97bf684d5.zip
Py3k compatibility patch #6 by Ali Polatel <hawking@g.o>.
Replace dict.has_key() calls with "in" and "not in" operators. svn path=/main/trunk/; revision=10875
-rw-r--r--pym/portage/__init__.py4
-rw-r--r--pym/portage/cache/mappings.py11
-rw-r--r--pym/portage/cache/template.py4
3 files changed, 18 insertions, 1 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index d5b82ec13..06193e717 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -30,6 +30,7 @@ try:
import UserDict
from itertools import chain, izip
import platform
+ import warnings
except ImportError, e:
sys.stderr.write("\n\n")
sys.stderr.write("!!! Failed to complete python imports. These are internal modules for\n")
@@ -2759,6 +2760,9 @@ class config(object):
return v
def has_key(self,mykey):
+ warnings.warn("portage.config.has_key() is deprecated, "
+ "use the in operator instead",
+ DeprecationWarning)
return mykey in self
def __contains__(self, mykey):
diff --git a/pym/portage/cache/mappings.py b/pym/portage/cache/mappings.py
index 2ccc96b05..d0ca487f0 100644
--- a/pym/portage/cache/mappings.py
+++ b/pym/portage/cache/mappings.py
@@ -4,6 +4,7 @@
# $Id$
import UserDict
+import warnings
import weakref
class ProtectedDict(UserDict.DictMixin):
@@ -55,9 +56,14 @@ class ProtectedDict(UserDict.DictMixin):
return list(self.__iter__())
- def has_key(self, key):
+ def __contains__(self, key):
return key in self.new or (key not in self.blacklist and key in self.orig)
+ def has_key(self, key):
+ warnings.warn("portage.cache.mapping.ProtectedDict.has_key() is"
+ " deprecated, use the in operator instead",
+ DeprecationWarning)
+ return key in self
class LazyLoad(UserDict.DictMixin):
"""
@@ -91,6 +97,9 @@ class LazyLoad(UserDict.DictMixin):
def has_key(self, key):
+ warnings.warn("portage.cache.mappings.LazyLoad.has_key() is "
+ "deprecated, use the in operator instead",
+ DeprecationWarning)
return key in self
diff --git a/pym/portage/cache/template.py b/pym/portage/cache/template.py
index d5a07528c..891a5821f 100644
--- a/pym/portage/cache/template.py
+++ b/pym/portage/cache/template.py
@@ -6,6 +6,7 @@
from portage.cache import cache_errors
from portage.cache.cache_errors import InvalidRestriction
from portage.cache.mappings import ProtectedDict
+import warnings
class database(object):
# this is for metadata/cache transfer.
@@ -121,6 +122,9 @@ class database(object):
if self.has_key is database.has_key:
# prevent a possible recursive loop
raise NotImplementedError
+ warnings.warn("portage.cache.template.database.has_key() is "
+ "deprecated, override __contains__ instead",
+ DeprecationWarning)
return self.has_key(cpv)
def __iter__(self):