diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-06-02 07:00:16 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-06-08 08:59:20 +0200 |
commit | f401fe70d35c5e7b269510b788664bc55f9b28bf (patch) | |
tree | a02772ee634b9e2b8ee727ca10c0dd1b8a1d2019 /rtemsqual/interface.py | |
parent | spec: Fix attribute order (diff) | |
download | rtems-central-f401fe70d35c5e7b269510b788664bc55f9b28bf.tar.bz2 |
Use enumerate()
Diffstat (limited to 'rtemsqual/interface.py')
-rw-r--r-- | rtemsqual/interface.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/rtemsqual/interface.py b/rtemsqual/interface.py index 52ba0905..52f6e1ed 100644 --- a/rtemsqual/interface.py +++ b/rtemsqual/interface.py @@ -217,12 +217,10 @@ class Node: def generate_compound(self) -> None: """ Generates a compound (struct or union). """ with self._enum_struct_or_union(): - index = 0 - for definition in self.item["definition"]: + for index, definition in enumerate(self.item["definition"]): self.content.add( _add_definition(self, self.item, f"definition[{index}]", definition, Node._get_compound_definition)) - index += 1 def generate_enum(self) -> None: """ Generates an enum. """ @@ -316,13 +314,12 @@ class Node: content.append(f"{kind} {{") content.gap = False with content.indent(): - index = 0 - for compound_member in definition["definition"]: + for index, compound_member in enumerate( + definition["definition"]): content.add( _add_definition(self, item, f"definition[{index}]", compound_member, Node._get_compound_definition)) - index += 1 name = definition["name"] content.append(f"}} {name};") return content.lines |