Commit 4ae6549f8e1cd31076c6dbabef568689fc313a13

Authored by Paul Burton
Committed by sjg
1 parent f5d44b9bae

dtoc: Use items() to iterate over dictionaries in python 3.x

In python 3.x the iteritems() method has been removed from dictionaries,
and the items() method does effectively the same thing. On python 2.x
using items() is a little less efficient since it involves copying data,
but as speed isn't a concern in the affected code switch to using
items() anyway for simplicity.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Acked-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 5 additions and 5 deletions Side-by-side Diff

... ... @@ -224,14 +224,14 @@
224 224 fields = {}
225 225  
226 226 # Get a list of all the valid properties in this node.
227   - for name, prop in node.props.iteritems():
  227 + for name, prop in node.props.items():
228 228 if name not in PROP_IGNORE_LIST and name[0] != '#':
229 229 fields[name] = copy.deepcopy(prop)
230 230  
231 231 # If we've seen this node_name before, update the existing struct.
232 232 if node_name in structs:
233 233 struct = structs[node_name]
234   - for name, prop in fields.iteritems():
  234 + for name, prop in fields.items():
235 235 oldprop = struct.get(name)
236 236 if oldprop:
237 237 oldprop.Widen(prop)
... ... @@ -246,7 +246,7 @@
246 246 for node in self._valid_nodes:
247 247 node_name = self.GetCompatName(node)
248 248 struct = structs[node_name]
249   - for name, prop in node.props.iteritems():
  249 + for name, prop in node.props.items():
250 250 if name not in PROP_IGNORE_LIST and name[0] != '#':
251 251 prop.Widen(struct[name])
252 252 upto += 1
... ... @@ -298,7 +298,7 @@
298 298 var_name = Conv_name_to_c(node.name)
299 299 self.Buf('static struct %s%s %s%s = {\n' %
300 300 (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name))
301   - for pname, prop in node.props.iteritems():
  301 + for pname, prop in node.props.items():
302 302 if pname in PROP_IGNORE_LIST or pname[0] == '#':
303 303 continue
304 304 ptype = TYPE_NAMES[prop.type]
tools/dtoc/fdt_fallback.py
... ... @@ -58,7 +58,7 @@
58 58 This fills in the props and subnodes properties, recursively
59 59 searching into subnodes so that the entire tree is built.
60 60 """
61   - for name, byte_list_str in self._fdt.GetProps(self.path).iteritems():
  61 + for name, byte_list_str in self._fdt.GetProps(self.path).items():
62 62 prop = Prop(self, name, byte_list_str)
63 63 self.props[name] = prop
64 64