summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-12-01 14:22:23 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-12-01 14:27:40 +0100
commit1bc176399fac0a1599f3c4ed0528cb4148d35c8c (patch)
tree1b84f04127f24babef28d933f438539b6ee1eb89
parentspecview.py: Add "api" filter (diff)
downloadrtems-central-1bc176399fac0a1599f3c4ed0528cb4148d35c8c.tar.bz2
specview.py: Add "design" filter
-rwxr-xr-xspecview.py51
1 files changed, 50 insertions, 1 deletions
diff --git a/specview.py b/specview.py
index 10b14a7d..375f650b 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__":