aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-09-17 17:06:04 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-09-17 17:06:04 +0200
commitca5fb75953ae2a73d2d41ceff59e2688b11cbf2b (patch)
tree63072273df11216861b7929347e3b1a510b87a85
parent581044887a16d37c90116da544f5d9d600faa80c (diff)
fix flatten function
-rwxr-xr-xscripts/reqs2tex.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/scripts/reqs2tex.py b/scripts/reqs2tex.py
index db7e174..8c2236a 100755
--- a/scripts/reqs2tex.py
+++ b/scripts/reqs2tex.py
@@ -25,18 +25,19 @@ class REQ_PRIORITY(StrEnum):
COULD = 'could'
WONT = 'will not'
-# this doesn't work right
def flatten(data):
out = []
- # this key is a requirement
- if KEY.DESCRIPTION in data:
- out.append(data)
- # check for children
for key, value in data.items():
+ # this item is a requirement
+ if key == KEY.DESCRIPTION:
+ out.append(data)
+
# skip over reserved keys
if key in KEY: continue
+ # recursively flatten other requirements
items = flatten(value)
+ # and prefix them with the current key
for item in items:
if KEY.LABEL in item:
item[KEY.LABEL] = f"{key}.{item[KEY.LABEL]}"