summaryrefslogtreecommitdiffstats
path: root/rtemsqual
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-06-02 07:00:16 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-06-08 08:59:20 +0200
commitf401fe70d35c5e7b269510b788664bc55f9b28bf (patch)
treea02772ee634b9e2b8ee727ca10c0dd1b8a1d2019 /rtemsqual
parentspec: Fix attribute order (diff)
downloadrtems-central-f401fe70d35c5e7b269510b788664bc55f9b28bf.tar.bz2
Use enumerate()
Diffstat (limited to 'rtemsqual')
-rw-r--r--rtemsqual/content.py10
-rw-r--r--rtemsqual/interface.py9
-rw-r--r--rtemsqual/specverify.py4
3 files changed, 7 insertions, 16 deletions
diff --git a/rtemsqual/content.py b/rtemsqual/content.py
index bf07ebdd..29bf7bd2 100644
--- a/rtemsqual/content.py
+++ b/rtemsqual/content.py
@@ -201,8 +201,7 @@ class Content:
if not content:
return
lines = make_lines(content)
- index = 0
- for line in lines:
+ for index, line in enumerate(lines):
if line:
self._add_gap()
with context(self):
@@ -210,7 +209,6 @@ class Content:
_indent(lines[index:], self._indent,
self._empty_line_indent))
break
- index += 1
def wrap(self,
content: Optional[GenericContent],
@@ -277,15 +275,13 @@ class Content:
wrapper.initial_indent = ""
wrapper.subsequent_indent = ""
wrapper.width = 79 - len(self._indent)
- first = True
- for block in text.split("\n\n"):
+ for index, block in enumerate(text.split("\n\n")):
lines = wrapper.wrap(block)
- if first:
+ if index == 0:
if 0 < len(last) >= indent_len:
self._lines[-1] = last[0:indent_len] + lines[0]
lines = lines[1:]
self.gap = True
- first = False
else:
self._lines.append(self._empty_line_indent)
self._lines.extend(
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
diff --git a/rtemsqual/specverify.py b/rtemsqual/specverify.py
index 32badae2..a02d64c0 100644
--- a/rtemsqual/specverify.py
+++ b/rtemsqual/specverify.py
@@ -371,11 +371,9 @@ class _ItemVerifier(_Verifier):
def verify_list(self, path: _Path, value: Any, type_info: Any) -> Set[str]:
""" Verifies a list value. """
verifier = self._verifier_map[type_info["spec-type"]]
- index = 0
- for element in value:
+ for index, element in enumerate(value):
verifier.verify(_Path(path.item, path.path + f"[{index}]"),
element)
- index += 1
return set()
def verify_none(self, _path: _Path, _value: Any,