Likums "Par sabiedrisko pakalpojumu regulatoriem" (lv-lik-2000-10-19), konsolidētā redakcija uz 2026-04-03 no likumi.lv Word datnes. Datu līgums contracts/B20-likumi.odcs.yaml (datu kopa B20). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016679RwmHsuTFfxt26wP6rk
17 lines
766 B
Python
17 lines
766 B
Python
"""validate.py — pārbauda visus data/*.xml pret schemas/likumi-0.1.xsd un faila nosaukumu = @id."""
|
|
import glob, os, sys
|
|
from lxml import etree
|
|
here = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
xsd = etree.XMLSchema(etree.parse(os.path.join(here, "schemas", "likumi-0.1.xsd")))
|
|
bad = 0
|
|
for f in sorted(glob.glob(os.path.join(here, "data", "*.xml"))):
|
|
d = etree.parse(f)
|
|
ok = xsd.validate(d)
|
|
name_ok = os.path.basename(f) == d.getroot().get("id") + ".xml"
|
|
print(("OK " if ok and name_ok else "ERR ") + os.path.basename(f))
|
|
if not ok:
|
|
for e in xsd.error_log: print(" ", e.line, e.message)
|
|
if not name_ok: print(" faila nosaukums neatbilst @id")
|
|
bad += (not ok) or (not name_ok)
|
|
sys.exit(1 if bad else 0)
|