")
sys.stderr.write("!!! Failed to complete python imports. These are internal modules for
")
@@ -2767,6 +2768,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
class ProtectedDict(UserDict.DictMixin):
"""
@@ -54,9 +55,15 @@ 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):
"""
@@ -90,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 d5a0752..891a582 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):
--
1.5.6.1
--
gentoo-portage-dev@lists.gentoo.org mailing list
07-01-2008, 06:35 PM
"Alec Warner"
Add deprecation warnings to classes that have has_key() methods.
You should hardcode the warning somewhere.
also quote 'in', eg. 'please use the 'in' operator'
-Alec
On Tue, Jul 1, 2008 at 5:09 AM, Ali Polatel <hawking@gentoo.org> wrote:
> These don't apply to the trunk anymore.
> Updated patches can be found at: http://dev.gentoo.org/~hawking/py3k/portage/
>
> --
> Regards,
> Ali Polatel
> --
> gentoo-portage-dev@lists.gentoo.org mailing list
>
>
--
gentoo-portage-dev@lists.gentoo.org mailing list