remove has_key usage

authorAurelien Campeas <aurelien.campeas@logilab.fr>
changeset134b04defd20
branchstable
phasepublic
hiddenno
parent revision#042ea5e6e08c Add EXISTS, ILIKE, DISTINCT to KEYWORDS (closes #165898)
child revision#5cad47e1ffbf [gecode] fix build against gecode 4.2.0 (closes #167329)
files modified by this revision
compare.py
stmts.py
test/unittest_analyze.py
# HG changeset patch
# User Aurelien Campeas <aurelien.campeas@logilab.fr>
# Date 1372421491 -7200
# Fri Jun 28 14:11:31 2013 +0200
# Branch stable
# Node ID 134b04defd20a2e420b4a4154e5c2d97a7bf2d26
# Parent 042ea5e6e08cba1f6523c17641f72df4d55d8f4e
remove has_key usage

diff --git a/compare.py b/compare.py
@@ -114,11 +114,11 @@
1          keys.sort()
2          r_type = ':'.join(keys)
3          r_list = canon['restriction'].setdefault(r_type, [])
4          done = {}
5          for key in keys:
6 -            if done.has_key(key):
7 +            if key in done:
8                  continue
9              done[key] = None
10              for expr in canon_dict[key]:
11                  self.manage_relation(expr, canon, r_list)
12          raise SkipChildren()
diff --git a/stmts.py b/stmts.py
@@ -42,11 +42,11 @@
13              # be careful, Variable and VariableRef define __cmp__
14              if not [v for v in varrefs if v is vref]:
15                  raise AssertionError('vref %r is not in the tree' % vref)
16              refs[id(vref)] = 1
17      for vref in varrefs:
18 -        if not refs.has_key(id(vref)):
19 +        if id(vref) not in refs:
20              raise AssertionError('vref %r is not referenced (%r)' % (vref, vref.stmt))
21      return True
22 
23  class undo_modification(object):
24      def __init__(self, select):
@@ -996,11 +996,11 @@
25 
26      def add_main_relation(self, relation):
27          """add a relation to the list of inserted relations"""
28          var = relation.children[0].variable
29          rhs = relation.children[1]
30 -        if not self.inserted_variables.has_key(var):
31 +        if var not in self.inserted_variables:
32              if isinstance(rhs, nodes.Constant):
33                  msg = 'Using variable %s in declaration but %s is not an \
34  insertion variable'
35                  raise BadRQLQuery(msg % (var, var))
36          relation.parent = self
diff --git a/test/unittest_analyze.py b/test/unittest_analyze.py
@@ -168,14 +168,14 @@
37 
38      def relations(self):
39          return self._relations.keys()
40 
41      def has_entity(self, e_type):
42 -        return self._types.has_key(e_type)
43 +        return e_type in self._types
44 
45      def has_relation(self, r_type):
46 -        return self._relations.has_key(r_type)
47 +        return r_type in self._relations
48 
49      def __contains__(self, ertype):
50          return self.has_entity(ertype) or self.has_relation(ertype)
51 
52      def rschema(self, r_type):