# -*- coding: utf-8 -*- import json, re, os BASE=os.path.dirname(__file__) mp=os.path.join(BASE,"mapping.json") d=json.load(open(mp,encoding="utf-8")) def clean(s): # entferne Handlebars-Conditional-Wrapper, behalte Innentext s=re.sub(r"\{\{#if \w+\}\}","",s) s=re.sub(r"\{\{/if\}\}","",s) s=re.sub(r"\s+"," ",s).strip() s=s.replace(" .",".").replace(" ,",",") return s for a in d["anforderungen"]: a["requirement"]=clean(a["requirement"]) a["implementation"]=clean(a["implementation"]) if a["policy"]=="L00": a["impl_anchor"]=a["req_anchor"] # Leitlinie: kombiniert json.dump(d,open(mp,"w",encoding="utf-8"),ensure_ascii=False,indent=1) print("mapping bereinigt:",len(d["anforderungen"]),"Eintraege")