1 |
--- |
2 |
pym/portage/__init__.py | 4 ++++ |
3 |
pym/portage/cache/mappings.py | 12 +++++++++++- |
4 |
pym/portage/cache/template.py | 4 ++++ |
5 |
3 files changed, 19 insertions(+), 1 deletions(-) |
6 |
|
7 |
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py |
8 |
index 9e29435..1564aba 100644 |
9 |
--- a/pym/portage/__init__.py |
10 |
+++ b/pym/portage/__init__.py |
11 |
@@ -30,6 +30,7 @@ try: |
12 |
import UserDict |
13 |
from itertools import chain, izip |
14 |
import platform |
15 |
+ import warnings |
16 |
except ImportError, e: |
17 |
sys.stderr.write("\n\n") |
18 |
sys.stderr.write("!!! Failed to complete python imports. These are internal modules for\n") |
19 |
@@ -2767,6 +2768,9 @@ class config(object): |
20 |
return v |
21 |
|
22 |
def has_key(self,mykey): |
23 |
+ warnings.warn("portage.config.has_key() is deprecated, " |
24 |
+ "use the in operator instead", |
25 |
+ DeprecationWarning) |
26 |
return mykey in self |
27 |
|
28 |
def __contains__(self, mykey): |
29 |
diff --git a/pym/portage/cache/mappings.py b/pym/portage/cache/mappings.py |
30 |
index 9aa5a21..55616ca 100644 |
31 |
--- a/pym/portage/cache/mappings.py |
32 |
+++ b/pym/portage/cache/mappings.py |
33 |
@@ -4,6 +4,7 @@ |
34 |
# $Id$ |
35 |
|
36 |
import UserDict |
37 |
+import warnings |
38 |
|
39 |
class ProtectedDict(UserDict.DictMixin): |
40 |
""" |
41 |
@@ -54,9 +55,15 @@ class ProtectedDict(UserDict.DictMixin): |
42 |
return list(self.__iter__()) |
43 |
|
44 |
|
45 |
- def has_key(self, key): |
46 |
+ def __contains__(self, key): |
47 |
return key in self.new or (key not in self.blacklist and key in self.orig) |
48 |
|
49 |
+ def has_key(self, key): |
50 |
+ warnings.warn("portage.cache.mapping.ProtectedDict.has_key() is" |
51 |
+ " deprecated, use the in operator instead", |
52 |
+ DeprecationWarning) |
53 |
+ return key in self |
54 |
+ |
55 |
|
56 |
class LazyLoad(UserDict.DictMixin): |
57 |
""" |
58 |
@@ -90,6 +97,9 @@ class LazyLoad(UserDict.DictMixin): |
59 |
|
60 |
|
61 |
def has_key(self, key): |
62 |
+ warnings.warn("portage.cache.mappings.LazyLoad.has_key() is " |
63 |
+ "deprecated, use the in operator instead", |
64 |
+ DeprecationWarning) |
65 |
return key in self |
66 |
|
67 |
|
68 |
diff --git a/pym/portage/cache/template.py b/pym/portage/cache/template.py |
69 |
index d5a0752..891a582 100644 |
70 |
--- a/pym/portage/cache/template.py |
71 |
+++ b/pym/portage/cache/template.py |
72 |
@@ -6,6 +6,7 @@ |
73 |
from portage.cache import cache_errors |
74 |
from portage.cache.cache_errors import InvalidRestriction |
75 |
from portage.cache.mappings import ProtectedDict |
76 |
+import warnings |
77 |
|
78 |
class database(object): |
79 |
# this is for metadata/cache transfer. |
80 |
@@ -121,6 +122,9 @@ class database(object): |
81 |
if self.has_key is database.has_key: |
82 |
# prevent a possible recursive loop |
83 |
raise NotImplementedError |
84 |
+ warnings.warn("portage.cache.template.database.has_key() is " |
85 |
+ "deprecated, override __contains__ instead", |
86 |
+ DeprecationWarning) |
87 |
return self.has_key(cpv) |
88 |
|
89 |
def __iter__(self): |
90 |
-- |
91 |
1.5.6.1 |
92 |
|
93 |
-- |
94 |
gentoo-portage-dev@l.g.o mailing list |