summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpierre-yves david <pierre-yves.david@insa-lyon.fr>2008-10-19 23:25:39 +0200
committerpierre-yves david <pierre-yves.david@insa-lyon.fr>2008-10-19 23:25:39 +0200
commitfe08edd82ae7594b7edc9ab3d084643d812402f3 (patch)
tree8edf0df5416048ffd7d655f4ae2cd37713a07705
parentd79d1b8ceebe87d76c4226167b06f3d4dee90656 (diff)
downloadlogilab-common-fe08edd82ae7594b7edc9ab3d084643d812402f3.tar.gz
replace all has_key call with "element in dict" statement (3.x compat)
-rw-r--r--__init__.py4
-rw-r--r--bind.py6
-rw-r--r--cache.py2
-rw-r--r--cli.py6
-rw-r--r--configuration.py8
-rw-r--r--patricia.py4
-rw-r--r--test/unittest_cache.py2
7 files changed, 16 insertions, 16 deletions
diff --git a/__init__.py b/__init__.py
index 64d7cce..f5bc28d 100644
--- a/__init__.py
+++ b/__init__.py
@@ -46,7 +46,7 @@ def intersection(list1, list2):
for item in list1:
intersect_dict[item] = 1
for item in list2:
- if intersect_dict.has_key(item):
+ if item in intersect_dict:
result.append(item)
return result
@@ -58,7 +58,7 @@ def difference(list1, list2):
for i in list2:
tmp[i] = 1
for i in list1:
- if not tmp.has_key(i):
+ if i not in tmp:
result.append(i)
return result
diff --git a/bind.py b/bind.py
index b5f99f8..275ab8b 100644
--- a/bind.py
+++ b/bind.py
@@ -48,7 +48,7 @@ def bind_code(co, globals):
oparg = None
if op == LOAD_GLOBAL:
name = co.co_names[oparg]
- if globals.has_key(name):
+ if name in globals:
k = assigned.get(name, None)
if k == None:
k = len(consts)
@@ -139,7 +139,7 @@ def analyze_code(co, globals, consts_dict, consts_list):
if op == LOAD_GLOBAL:
name = co.co_names[oparg]
- if globals.has_key(name):
+ if name in globals:
k = consts_dict.get(name, None)
if k == None:
k = len(consts_list)
@@ -147,7 +147,7 @@ def analyze_code(co, globals, consts_dict, consts_list):
consts_list.append(globals[name])
if op == STORE_GLOBAL:
name = co.co_names[oparg]
- if globals.has_key(name):
+ if name in globals:
modified_globals.append(name)
return modified_globals
diff --git a/cache.py b/cache.py
index 05373a6..4600a1c 100644
--- a/cache.py
+++ b/cache.py
@@ -78,7 +78,7 @@ class Cache(dict):
clear = locked(_acquire, _release)(clear)
def pop(self, key, default=_marker):
- if super(Cache, self).has_key(key):
+ if key in super(Cache, self):
self._usage.remove(key)
#if default is _marker:
# return super(Cache, self).pop(key)
diff --git a/cli.py b/cli.py
index 8c37f77..977ceca 100644
--- a/cli.py
+++ b/cli.py
@@ -101,7 +101,7 @@ class CLIHelper:
if not s_line:
continue
args = s_line.split()
- if self.commands.has_key(args[0]):
+ if args[0] in self.commands:
try:
cmd = 'do_%s' % self.commands[args[0]]
getattr(self, cmd)(*args[1:])
@@ -152,9 +152,9 @@ class CLIHelper:
def do_help(self, command=None) :
"""base input of the help system"""
- if self._command_help.has_key(command):
+ if command in self._command_help:
self._print_help(*self._command_help[command])
- elif command is None or not self._topics.has_key(command):
+ elif command is None or command not in self._topics:
print _("Use help <topic> or help <command>.")
print _("Available topics are:")
topics = self._topics.keys()
diff --git a/configuration.py b/configuration.py
index b0c8e2d..ca3254a 100644
--- a/configuration.py
+++ b/configuration.py
@@ -183,7 +183,7 @@ VALIDATORS = {'string' : unquote,
}
def _call_validator(opttype, optdict, option, value):
- if not VALIDATORS.has_key(opttype):
+ if opttype not in VALIDATORS:
raise Exception('Unsupported type "%s"' % opttype)
try:
return VALIDATORS[opttype](optdict, option, value)
@@ -358,7 +358,7 @@ class OptionsManagerMixIn(object):
else:
self.options_providers.append(provider)
non_group_spec_options = [option for option in provider.options
- if not option[1].has_key('group')]
+ if 'group' not in option[1]]
groups = getattr(provider, 'option_groups', ())
if own_group:
self.add_option_group(provider.name.upper(), provider.__doc__,
@@ -395,7 +395,7 @@ class OptionsManagerMixIn(object):
use with optik/optparse
"""
opt_dict = copy(opt_dict)
- if opt_dict.has_key('action'):
+ if 'action' in opt_dict:
self._nocallback_options[provider] = opt_name
else:
opt_dict['action'] = 'callback'
@@ -407,7 +407,7 @@ class OptionsManagerMixIn(object):
opt_dict['help'] += ' [current: %default]'
del opt_dict['default']
args = ['--' + opt_name]
- if opt_dict.has_key('short'):
+ if 'short' in opt_dict:
self._short_options[opt_dict['short']] = opt_name
args.append('-' + opt_dict['short'])
del opt_dict['short']
diff --git a/patricia.py b/patricia.py
index 09e9d9d..cf34a8e 100644
--- a/patricia.py
+++ b/patricia.py
@@ -71,7 +71,7 @@ class PatriciaNode:
n.edges[e] = self
return n
n_pfx, n_e, n_sfx = split(len(self.value), string)
- if self.edges.has_key(n_e):
+ if n_e in self.edges:
self.edges[n_e] = self.edges[n_e].insert(n_sfx, data)
else:
self.edges[n_e] = PatriciaNode(n_sfx, 1, data)
@@ -111,7 +111,7 @@ class PatriciaNode:
sfxs = []
if pfx and self.value[:len(pfx)] != pfx:
pfx, e, sfx = split(len(self.value), pfx)
- if self.value == pfx and self.edges.has_key(e):
+ if self.value == pfx and e in self.edges:
sfxs = ['%s%s%s' % (self.value, e, sfx)
for sfx in self.edges[e].pfx_search(sfx, depth)]
else:
diff --git a/test/unittest_cache.py b/test/unittest_cache.py
index 8e7b998..ae96610 100644
--- a/test/unittest_cache.py
+++ b/test/unittest_cache.py
@@ -51,7 +51,7 @@ class CacheTestCase(TestCase):
self.cache[4] = 'foz'
self.cache[5] = 'fuz'
self.cache[6] = 'spam'
- self.assert_(not self.cache.has_key(1),
+ self.assert_(1 not in self.cache,
'key 1 has not been suppressed from the cache dictionnary')
self.assert_(1 not in self.cache._usage,
'key 1 has not been suppressed from the cache LRU list')