1
0

NAP2027 0.1.1: labotas uzdevumu [315]–[318] ailes; pašreizējā institūcija (KEM)

Uzdevumu teksta pirmie vārdi 68. lpp. bija nonākuši ailē „Nr.”; pārbaudei
pievienota apgrieztā vārdu pārbaude. Atribūts currentOrg/currentSince:
septiņiem VARAM vides un klimata uzdevumiem — KEM 20-0000.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016679RwmHsuTFfxt26wP6rk
This commit is contained in:
2026-10-11 13:01:14 +00:00
parent bcdd26b8d9
commit bc915bc6d2
10 changed files with 114 additions and 37 deletions

View File

@@ -47,7 +47,7 @@ def main(src, out):
d = json.load(open(src, encoding="utf-8"))
m = yaml.safe_load(open(os.path.join(ROOT, "sources/nap2027/dalibnieki.yaml"), encoding="utf-8"))
actors = {x["label"]: x for x in m["actors"]}
used_actors, used_funding, unresolved = {}, {}, []
used_actors, used_funding, unresolved, used_current = {}, {}, [], set()
# ---------------------------------------------------------------- actors
def actor_list(printed):
@@ -68,11 +68,19 @@ def main(src, out):
out_.append({"label": q, "org": actors[q].get("org")})
return out_
def actors_xml(tag, printed):
cur = {(n, c["label"]): c for c in m.get("current", []) for n in c["items"]}
def actors_xml(tag, printed, n=None):
lst = actor_list(printed)
for x in lst:
c = cur.get((n, x["label"]))
if c:
x["currentOrg"], x["currentSince"] = c["org"], c["since"]
used_current.add((n, x["label"]))
if not lst:
return ""
inner = "".join(f"<Actor{a('label', x['label'])}{a('org', x.get('org'))}{a('qualifier', x.get('qualifier'))}/>" for x in lst)
inner = "".join(f"<Actor{a('label', x['label'])}{a('org', x.get('org'))}{a('qualifier', x.get('qualifier'))}"
f"{a('currentOrg', x.get('currentOrg'))}{a('currentSince', x.get('currentSince'))}/>" for x in lst)
return f"<{tag}{a('printed', printed)}>{inner}</{tag}>"
# ---------------------------------------------------------------- funding
@@ -156,8 +164,8 @@ def main(src, out):
+ el("BaseValue", x.get("baseValue")) + el("Target", x.get("target2024"), year="2024")
+ el("Target", x.get("target2027"), year="2027") + el("DataSource", x.get("source")) + "</Indicator>")
elif x["kind"] == "task":
body = ("<Task>" + el("Text", x["text"]) + actors_xml("Responsible", x.get("responsible"))
+ actors_xml("CoResponsible", x.get("coResponsible")) + funding_xml(x.get("funding"))
body = ("<Task>" + el("Text", x["text"]) + actors_xml("Responsible", x.get("responsible"), x["number"])
+ actors_xml("CoResponsible", x.get("coResponsible"), x["number"]) + funding_xml(x.get("funding"))
+ task_indicators(x) + "</Task>")
else:
title = x.get("title") if x["kind"] == "strategicGoal" else None
@@ -235,6 +243,7 @@ def main(src, out):
+ el("Change", f"Pirmā versija: {len(d['items'])} numurētie punkti [1]–[475], {len(d['evidence'])} pamatojuma punkti, "
f"{len(d['footnotes'])} zemsvītras piezīmes, {len(d['abbreviations'])} saīsinājumi.")
+ el("Change", "Atbildīgās un līdzatbildīgās institūcijas sasaistītas ar VPK ID; drukātais apzīmējums saglabāts.")
+ el("Change", "Uzdevumiem, kuru jomu pārņēmusi Klimata un enerģētikas ministrija (klimata politika no 2023-01-01, vides aizsardzības politika no 2024-07-01), pie VARAM norādīta pašreizējā institūcija (currentOrg).")
+ "</DataVersion></Metadata>")
xml = ('<?xml version="1.0" encoding="UTF-8"?>\n'
@@ -248,6 +257,10 @@ def main(src, out):
with open(out, "wb") as f:
f.write(etree.tostring(tree, xml_declaration=True, encoding="UTF-8", pretty_print=True))
print("wrote", out, "actors", len(used_actors), "funding", len(used_funding), "indicator links", match_stats)
want = {(n, c["label"]) for c in m.get("current", []) for n in c["items"]}
if want - used_current:
unresolved += [f"current: {k}" for k in sorted(want - used_current)]
print("current institution set for", len(used_current), "task actors")
if unresolved:
print("UNRESOLVED", sorted(set(unresolved)))
sys.exit(1)