Linter lintet jetzt auch werke

This commit is contained in:
Simon Martens
2025-09-29 20:31:23 +02:00
parent ef536ade48
commit 3146507605
2 changed files with 117 additions and 9 deletions

View File

@@ -20,11 +20,15 @@ def get_all_ids(root, tag):
def check_references(beitrag_root, reference_data, filepath):
errors = []
relative_path = os.path.relpath(filepath, REPO_ROOT)
for ref_type, ref_tag in [('akteur', 'akteur'), ('kategorie', 'kategorie'),
for ref_type, ref_tag in [('akteur', 'akteur'), ('kategorie', 'kategorie'),
('ort', 'ort'), ('werk', 'werk')]:
for ref in beitrag_root.xpath(f'//kgpz:{ref_tag}', namespaces=NAMESPACE):
# Skip elements that have an 'id' attribute (they are definitions, not references)
if ref.get('id') is not None:
continue
ref_id = ref.get('ref')
if ref_id not in reference_data[ref_type]:
if ref_id and ref_id not in reference_data[ref_type]:
line_number = ref.sourceline
errors.append(f"{relative_path}, Zeile {line_number}: UNGÜLTIGER VERWEIS ({ref_type}:{ref_id})")
return errors
@@ -39,14 +43,33 @@ def main():
all_errors = []
# Check all XML files in XML directory
xml_files_to_check = []
# Add core data files
for filename in ['akteure.xml', 'kategorien.xml', 'orte.xml', 'werke.xml']:
xml_files_to_check.append(os.path.join(XML_DIR, filename))
# Add all files in beitraege/
beitraege_dir = os.path.join(XML_DIR, 'beitraege')
for filename in os.listdir(beitraege_dir):
if filename.endswith('-beitraege.xml'):
filepath = os.path.join(beitraege_dir, filename)
beitrag_root = parse_xml_file(filepath)
if beitrag_root is not None:
errors = check_references(beitrag_root, reference_data, filepath)
all_errors.extend(errors)
if os.path.exists(beitraege_dir):
for filename in os.listdir(beitraege_dir):
if filename.endswith('.xml'):
xml_files_to_check.append(os.path.join(beitraege_dir, filename))
# Add all files in stuecke/
stuecke_dir = os.path.join(XML_DIR, 'stuecke')
if os.path.exists(stuecke_dir):
for filename in os.listdir(stuecke_dir):
if filename.endswith('.xml'):
xml_files_to_check.append(os.path.join(stuecke_dir, filename))
# Check all collected files
for filepath in xml_files_to_check:
root = parse_xml_file(filepath)
if root is not None:
errors = check_references(root, reference_data, filepath)
all_errors.extend(errors)
all_errors.sort()

View File

@@ -0,0 +1,85 @@
XML/werke.xml, Zeile 1028: UNGÜLTIGER VERWEIS (akteur:rambach-jj)
XML/werke.xml, Zeile 1282: UNGÜLTIGER VERWEIS (akteur:thilo-ca)
XML/werke.xml, Zeile 1481: UNGÜLTIGER VERWEIS (akteur:galiani)
XML/werke.xml, Zeile 1487: UNGÜLTIGER VERWEIS (akteur:noesselt)
XML/werke.xml, Zeile 1567: UNGÜLTIGER VERWEIS (akteur:remond-t)
XML/werke.xml, Zeile 2057: UNGÜLTIGER VERWEIS (akteur:graefin-vergy)
XML/werke.xml, Zeile 2172: UNGÜLTIGER VERWEIS (akteur:brandes-jc)
XML/werke.xml, Zeile 2178: UNGÜLTIGER VERWEIS (akteur:sprengel-pn)
XML/werke.xml, Zeile 2240: UNGÜLTIGER VERWEIS (akteur:ellis-j)
XML/werke.xml, Zeile 2347: UNGÜLTIGER VERWEIS (akteur:weidner-gf)
XML/werke.xml, Zeile 2674: UNGÜLTIGER VERWEIS (akteur:freye-oekonomische-gesellschaft)
XML/werke.xml, Zeile 2768: UNGÜLTIGER VERWEIS (akteur:pontoppidan-e)
XML/werke.xml, Zeile 29: UNGÜLTIGER VERWEIS (akteur:pfeffel)
XML/werke.xml, Zeile 3044: UNGÜLTIGER VERWEIS (akteur:hiller-a)
XML/werke.xml, Zeile 3172: UNGÜLTIGER VERWEIS (akteur:graser-r)
XML/werke.xml, Zeile 3338: UNGÜLTIGER VERWEIS (akteur:remond-t)
XML/werke.xml, Zeile 3366: UNGÜLTIGER VERWEIS (akteur:fuessli-jr)
XML/werke.xml, Zeile 3445: UNGÜLTIGER VERWEIS (akteur:guthrie)
XML/werke.xml, Zeile 3478: UNGÜLTIGER VERWEIS (akteur:walch-cfw)
XML/werke.xml, Zeile 3547: UNGÜLTIGER VERWEIS (akteur:tschudi-jj)
XML/werke.xml, Zeile 3576: UNGÜLTIGER VERWEIS (akteur:kahl-jc)
XML/werke.xml, Zeile 3582: UNGÜLTIGER VERWEIS (akteur:brittisches-museum)
XML/werke.xml, Zeile 3755: UNGÜLTIGER VERWEIS (akteur:rambach-fc)
XML/werke.xml, Zeile 3774: UNGÜLTIGER VERWEIS (akteur:schelz-fg)
XML/werke.xml, Zeile 3877: UNGÜLTIGER VERWEIS (akteur:miller-jp)
XML/werke.xml, Zeile 4107: UNGÜLTIGER VERWEIS (akteur:adelung-jc)
XML/werke.xml, Zeile 4219: UNGÜLTIGER VERWEIS (akteur:boehm-m)
XML/werke.xml, Zeile 4292: UNGÜLTIGER VERWEIS (akteur:king-j)
XML/werke.xml, Zeile 4310: UNGÜLTIGER VERWEIS (akteur:tubel-cg)
XML/werke.xml, Zeile 4352: UNGÜLTIGER VERWEIS (akteur:reich-jcf)
XML/werke.xml, Zeile 4364: UNGÜLTIGER VERWEIS (akteur:benson-g)
XML/werke.xml, Zeile 4365: UNGÜLTIGER VERWEIS (akteur:bamberger-jp)
XML/werke.xml, Zeile 4521: UNGÜLTIGER VERWEIS (akteur:cotes-h)
XML/werke.xml, Zeile 4551: UNGÜLTIGER VERWEIS (akteur:weisse)
XML/werke.xml, Zeile 4569: UNGÜLTIGER VERWEIS (akteur:sterne)
XML/werke.xml, Zeile 4576: UNGÜLTIGER VERWEIS (akteur:sterne)
XML/werke.xml, Zeile 4617: UNGÜLTIGER VERWEIS (akteur:schultz-s)
XML/werke.xml, Zeile 4630: UNGÜLTIGER VERWEIS (akteur:zachariae-jfw)
XML/werke.xml, Zeile 4651: UNGÜLTIGER VERWEIS (akteur:vierordt-fm)
XML/werke.xml, Zeile 4678: UNGÜLTIGER VERWEIS (akteur:reckert-kc)
XML/werke.xml, Zeile 4871: UNGÜLTIGER VERWEIS (akteur:buesching-af)
XML/werke.xml, Zeile 4883: UNGÜLTIGER VERWEIS (akteur:mendelssohn-m)
XML/werke.xml, Zeile 4927: UNGÜLTIGER VERWEIS (akteur:warburton-w)
XML/werke.xml, Zeile 4953: UNGÜLTIGER VERWEIS (akteur:hawkesworth-j)
XML/werke.xml, Zeile 5082: UNGÜLTIGER VERWEIS (akteur:miller-jp)
XML/werke.xml, Zeile 520: UNGÜLTIGER VERWEIS (akteur:philippi-ja)
XML/werke.xml, Zeile 5244: UNGÜLTIGER VERWEIS (akteur:michaelis)
XML/werke.xml, Zeile 5251: UNGÜLTIGER VERWEIS (akteur:cramer-r)
XML/werke.xml, Zeile 5292: UNGÜLTIGER VERWEIS (akteur:gomperz-l)
XML/werke.xml, Zeile 5470: UNGÜLTIGER VERWEIS (akteur:hausen-cf)
XML/werke.xml, Zeile 5672: UNGÜLTIGER VERWEIS (akteur:michaelis)
XML/werke.xml, Zeile 5680: UNGÜLTIGER VERWEIS (akteur:meister-fa)
XML/werke.xml, Zeile 5804: UNGÜLTIGER VERWEIS (akteur:stafford-h)
XML/werke.xml, Zeile 5862: UNGÜLTIGER VERWEIS (akteur:mellin-jc)
XML/werke.xml, Zeile 5885: UNGÜLTIGER VERWEIS (akteur:sprenger-b)
XML/werke.xml, Zeile 5957: UNGÜLTIGER VERWEIS (akteur:boysen-fa)
XML/werke.xml, Zeile 6023: UNGÜLTIGER VERWEIS (akteur:rabener-wr)
XML/werke.xml, Zeile 6146: UNGÜLTIGER VERWEIS (akteur:volatire)
XML/werke.xml, Zeile 6326: UNGÜLTIGER VERWEIS (akteur:goldhagen-je)
XML/werke.xml, Zeile 6424: UNGÜLTIGER VERWEIS (akteur:thomas-dh)
XML/werke.xml, Zeile 6473: UNGÜLTIGER VERWEIS (akteur:ringeltaube-j)
XML/werke.xml, Zeile 6479: UNGÜLTIGER VERWEIS (akteur:friederici-jc)
XML/werke.xml, Zeile 6511: UNGÜLTIGER VERWEIS (akteur:gesner-js)
XML/werke.xml, Zeile 6531: UNGÜLTIGER VERWEIS (akteur:shaw-t)
XML/werke.xml, Zeile 6540: UNGÜLTIGER VERWEIS (akteur:floegel-kf)
XML/werke.xml, Zeile 6664: UNGÜLTIGER VERWEIS (akteur:beaumelle-a)
XML/werke.xml, Zeile 6725: UNGÜLTIGER VERWEIS (akteur:leyding-jd)
XML/werke.xml, Zeile 6886: UNGÜLTIGER VERWEIS (akteur:elsner-jt)
XML/werke.xml, Zeile 6913: UNGÜLTIGER VERWEIS (akteur:goeze-jm)
XML/werke.xml, Zeile 6923: UNGÜLTIGER VERWEIS (akteur:goeze-jm)
XML/werke.xml, Zeile 7038: UNGÜLTIGER VERWEIS (akteur:fordyce-j)
XML/werke.xml, Zeile 7080: UNGÜLTIGER VERWEIS (akteur:leyding-jd)
XML/werke.xml, Zeile 7134: UNGÜLTIGER VERWEIS (akteur:holberg)
XML/werke.xml, Zeile 7139: UNGÜLTIGER VERWEIS (akteur:holberg)
XML/werke.xml, Zeile 7202: UNGÜLTIGER VERWEIS (akteur:adelung-jc)
XML/werke.xml, Zeile 7208: UNGÜLTIGER VERWEIS (akteur:krueger-ck)
XML/werke.xml, Zeile 7223: UNGÜLTIGER VERWEIS (akteur:romanus-kf)
XML/werke.xml, Zeile 7251: UNGÜLTIGER VERWEIS (akteur:lessing)
XML/werke.xml, Zeile 7268: UNGÜLTIGER VERWEIS (akteur:chamfort-n)
XML/werke.xml, Zeile 7357: UNGÜLTIGER VERWEIS (akteur:lessing)
XML/werke.xml, Zeile 861: UNGÜLTIGER VERWEIS (akteur:adelung)
XML/werke.xml, Zeile 881: UNGÜLTIGER VERWEIS (akteur:sale-a)
XML/werke.xml, Zeile 918: UNGÜLTIGER VERWEIS (akteur:sulzer)
XML/werke.xml, Zeile 947: UNGÜLTIGER VERWEIS (akteur:gesner-js)
XML/werke.xml, Zeile 948: UNGÜLTIGER VERWEIS (akteur:trotz-ma)