diff --git a/lib/create_tos.py b/lib/create_tos.py index 4d3cf2c..93b445a 100644 --- a/lib/create_tos.py +++ b/lib/create_tos.py @@ -13,8 +13,34 @@ Codebereich liegt bei Calk Link 10 - Dort dann die Powershell "Tomcat-IIS_reset" ausführen. """ +def get_children_keys(tos_hierarchy, currentId, result): + if currentId not in tos_hierarchy: + return None + childIds = tos_hierarchy[currentId]["reference-ids"].values() + level = tos_hierarchy[currentId]["TOS-level"] + if len(childIds) > 0: + for cId in childIds: + result[cId] = level + for cId in childIds: + get_children_keys(tos_hierarchy, cId, result) +def get_all_keywords(tos_hierarchy): + # hole dir das erste Keyword + rootid = tos_hierarchy["root"] + # und von dort aus alle Referenzen + result = dict() + get_children_keys(tos_hierarchy, rootid, result) + return result + +def get_keywords_of_level(allKeywords, levelnum): + ret = list() + for kw in allKeywords: + if allKeywords[kw] == levelnum: + ret.append(kw) + return ret + + def create_tos_string(config_path): res = 'CalcMaster=EdmCodVal("' @@ -22,11 +48,14 @@ def create_tos_string(config_path): tos_hierarchy = "" with open(config_path, 'r', encoding='utf-8') as fh: tos_hierarchy = json.loads(fh.read()) - print(tos_hierarchy) - r = tos_hierarchy["root"] + allKeywords = get_all_keywords(tos_hierarchy) - myTuple = ("John", "Peter", "Vicky") - res += '")&EdmCodVal("'.join(myTuple) + myIds = list() + for level in range(1,5): + myIds.extend(get_keywords_of_level(allKeywords, level)) + print(myIds) + + res += '")&EdmCodVal("'.join(myIds) res += '")' return res else: