[rtems-central commit] specview.py: Add "design" filter
Sebastian Huber
sebh at rtems.org
Wed Dec 1 13:22:57 UTC 2021
Module: rtems-central
Branch: master
Commit: 1bc176399fac0a1599f3c4ed0528cb4148d35c8c
Changeset: http://git.rtems.org/rtems-central/commit/?id=1bc176399fac0a1599f3c4ed0528cb4148d35c8c
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Dec 1 14:22:23 2021 +0100
specview.py: Add "design" filter
---
specview.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 50 insertions(+), 1 deletion(-)
diff --git a/specview.py b/specview.py
index 10b14a7..375f650 100755
--- a/specview.py
+++ b/specview.py
@@ -232,6 +232,53 @@ def _no_validation(item: Item, path: List[str],
return path_2[:-1]
+def _is_refinement(item: Item, other: Item) -> bool:
+ for parent in item.parents(["interface-function", "requirement-refinement"]):
+ if parent == other:
+ return True
+ if _is_refinement(parent, other):
+ return True
+ return False
+
+
+_GROUPS = ["requirement/non-functional/design-group", "interface/group"]
+
+
+def _gather_design_components(item: Item, components: List[str]) -> bool:
+ if item.type in _GROUPS:
+ components.append(item)
+ return True
+ elif item.type.startswith("requirement"):
+ for parent in item.parents("interface-function"):
+ components.append(parent)
+ for parent in item.parents("requirement-refinement"):
+ _gather_design_components(parent, components)
+ return True
+ return False
+
+
+def _design(item_cache: ItemCache, enabled: List[str]) -> None:
+ for item in item_cache.all.values():
+ if not item.is_enabled(enabled):
+ continue
+ components = []
+ if not _gather_design_components(item, components):
+ continue
+ compact = set()
+ for component in components:
+ for component_2 in components:
+ if component != component_2:
+ if _is_refinement(component_2, component):
+ break
+ else:
+ compact.add(component)
+ if compact:
+ text = ", ".join(component.uid for component in compact)
+ else:
+ text = "N/A"
+ print(f"{item.uid}\t{text}")
+
+
def _gather_interface_placement(item: Item, spec: Set) -> None:
for child in item.children("interface-placement"):
spec.add(child)
@@ -369,7 +416,7 @@ def main() -> None:
parser.add_argument('--filter',
choices=[
"none", "api", "orphan", "no-validation",
- "action-table", "action-list"
+ "action-table", "action-list", "design"
],
type=str.lower,
default="none",
@@ -417,6 +464,8 @@ def main() -> None:
elif args.filter == "api":
_validate(root, enabled)
_list_api(item_cache)
+ elif args.filter == "design":
+ _design(item_cache, enabled)
if __name__ == "__main__":
More information about the vc
mailing list