[py3k] use dict.items() / dict.values() instead of .iter*

authorRémi Cardona <remi.cardona@free.fr>
changeset0eb748dcad73
branchdefault
phasepublic
hiddenno
parent revision#26c9ffb2fb47 [py3k] Use metaclasses using six.add_metaclass
child revision#c1924b7d9a7e [py3k] explicitly build a list around dict methods, #b2a05088292d [py3k] explicitly build a list around dict methods
files modified by this revision
graph.py
registry.py
tasksqueue.py
testlib.py
# HG changeset patch
# User Rémi Cardona <remi.cardona@free.fr>
# Date 1406538090 -7200
# Mon Jul 28 11:01:30 2014 +0200
# Node ID 0eb748dcad737e48c27ebfe77ffc11d59aafd042
# Parent 26c9ffb2fb47c59f344b3af1a51b7fb7e2aba56a
[py3k] use dict.items() / dict.values() instead of .iter*

diff --git a/graph.py b/graph.py
@@ -62,11 +62,11 @@
1              self.emit('size="%s"' % size)
2          if charset:
3              assert charset.lower() in ('utf-8', 'iso-8859-1', 'latin1'), \
4                     'unsupported charset %s' % charset
5              self.emit('charset="%s"' % charset)
6 -        for param in sorted(additionnal_param.iteritems()):
7 +        for param in sorted(additionnal_param.items()):
8              self.emit('='.join(param))
9 
10      def get_source(self):
11          """returns self._source"""
12          if self._source is None:
diff --git a/registry.py b/registry.py
@@ -267,11 +267,11 @@
13          return getattr(obj, '__name__', id(obj))
14 
15      def initialization_completed(self):
16          """call method __registered__() on registered objects when the callback
17          is defined"""
18 -        for objects in self.itervalues():
19 +        for objects in self.values():
20              for objectcls in objects:
21                  registered = getattr(objectcls, '__registered__', None)
22                  if registered:
23                      registered(self)
24          if self.debugmode:
@@ -372,11 +372,11 @@
25 
26      def possible_objects(self, *args, **kwargs):
27          """return an iterator on possible objects in this registry for the given
28          context
29          """
30 -        for objects in self.itervalues():
31 +        for objects in self.values():
32              obj = self._select_best(objects,  *args, **kwargs)
33              if obj is None:
34                  continue
35              yield obj
36 
@@ -548,11 +548,11 @@
37          self.debugmode = debugmode
38 
39      def reset(self):
40          """clear all registries managed by this store"""
41          # don't use self.clear, we want to keep existing subdictionaries
42 -        for subdict in self.itervalues():
43 +        for subdict in self.values():
44              subdict.clear()
45          self._lastmodifs = {}
46 
47      def __getitem__(self, name):
48          """return the registry (dictionary of class objects) associated to
@@ -675,11 +675,11 @@
49              self.load_file(filepath, modname)
50          self.initialization_completed()
51 
52      def initialization_completed(self):
53          """call initialization_completed() on all known registries"""
54 -        for reg in self.itervalues():
55 +        for reg in self.values():
56              reg.initialization_completed()
57 
58      def _mdate(self, filepath):
59          """ return the modification date of a file path """
60          try:
@@ -753,11 +753,11 @@
61          """
62          self.info('loading %s from %s', module.__name__, module.__file__)
63          if hasattr(module, 'registration_callback'):
64              module.registration_callback(self)
65          else:
66 -            self.register_all(vars(module).itervalues(), module.__name__)
67 +            self.register_all(vars(module).values(), module.__name__)
68 
69      def _load_ancestors_then_object(self, modname, objectcls, butclasses=()):
70          """handle class registration according to rules defined in
71          :meth:`load_module`
72          """
@@ -927,11 +927,11 @@
73 
74 
75  _PREDICATES = {}
76 
77  def wrap_predicates(decorator):
78 -    for predicate in _PREDICATES.itervalues():
79 +    for predicate in _PREDICATES.values():
80          if not '_decorators' in predicate.__dict__:
81              predicate._decorators = set()
82          if decorator in predicate._decorators:
83              continue
84          predicate._decorators.add(decorator)
diff --git a/tasksqueue.py b/tasksqueue.py
@@ -30,11 +30,11 @@
85  PRIORITY = {
86      'LOW': LOW,
87      'MEDIUM': MEDIUM,
88      'HIGH': HIGH,
89      }
90 -REVERSE_PRIORITY = dict((values, key) for key, values in PRIORITY.iteritems())
91 +REVERSE_PRIORITY = dict((values, key) for key, values in PRIORITY.items())
92 
93 
94 
95  class PrioritizedTasksQueue(queue.Queue):
96 
diff --git a/testlib.py b/testlib.py
@@ -1049,11 +1049,11 @@
97                  errors["unexpected files"] = sfiles_a - sfiles_b
98                  errors["missing files"] = sfiles_b - sfiles_a
99 
100 
101                  msgs = [ "%s: %s"% (name, items)
102 -                    for name, items in errors.iteritems() if items]
103 +                    for name, items in errors.items() if items]
104 
105                  if msgs:
106                      msgs.insert(0, "%s and %s differ :" % (
107                          osp.join(path_a, ipath_a),
108                          osp.join(path_b, ipath_b),