FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Portage Developer

 
 
LinkBack Thread Tools
 
Old 07-01-2008, 11:26 AM
Ali Polatel
 
Default Add deprecation warnings to classes that have has_key() methods.

---
pym/portage/__init__.py | 4 ++++
pym/portage/cache/mappings.py | 12 +++++++++++-
pym/portage/cache/template.py | 4 ++++
3 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 9e29435..1564aba 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("

")
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

def __contains__(self, mykey):
diff --git a/pym/portage/cache/mappings.py b/pym/portage/cache/mappings.py
index 9aa5a21..55616ca 100644
--- a/pym/portage/cache/mappings.py
+++ b/pym/portage/cache/mappings.py
@@ -4,6 +4,7 @@
# $Id$

import UserDict
+import warnings

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
 
Old 07-01-2008, 06:35 PM
"Alec Warner"
 
Default 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
 

Thread Tools




All times are GMT. The time now is 10:51 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org