From ca5fb75953ae2a73d2d41ceff59e2688b11cbf2b Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Tue, 17 Sep 2024 17:06:04 +0200 Subject: fix flatten function --- scripts/reqs2tex.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'scripts') 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]}" -- cgit v1.2.3