aboutsummaryrefslogtreecommitdiff
path: root/src/ee/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/tools')
-rw-r--r--src/ee/tools/part_find_requirements.py29
-rw-r--r--src/ee/tools/templates/build.ninja.j28
2 files changed, 21 insertions, 16 deletions
diff --git a/src/ee/tools/part_find_requirements.py b/src/ee/tools/part_find_requirements.py
index 032db02..a13c3f2 100644
--- a/src/ee/tools/part_find_requirements.py
+++ b/src/ee/tools/part_find_requirements.py
@@ -1,26 +1,27 @@
import argparse
from pathlib import Path
-from ee.part import requirement, Part, PartDb, load_db, save_db
+from ee.part import requirement, Part, load_db
-def work(in_path: Path, out_path: Path):
+def work(in_path: Path, out_path: Path, report_path: Path):
in_parts = load_db(in_path)
- with out_path.open("w") as f:
- print("<root>", file=f)
- for xml in in_parts.iterparts():
- part = Part(xml)
+ requirements = []
+ for xml in in_parts.iterparts():
+ part = Part(xml)
- analysis = requirement.analyze_requirements(part)
+ analysis = requirement.analyze_requirements(part)
+ requirements.append(analysis)
- print("Part: {}. Found {} requirements".format(analysis.part.printable_reference,
- len(analysis.requirements)), file=f)
+ with report_path.open("w") as f:
+ for a in requirements:
+ print("{}\n{}\n".format(a.part.printable_reference, "=" * len(a.part.printable_reference)), file=f)
- for r in analysis.requirements:
- print(" {}".format(r), file=f)
+ for r in a.requirements:
+ print("* {}".format(str(r)), file=f)
- print("</root>", file=f)
+ print("", file=f)
parser = argparse.ArgumentParser()
@@ -34,6 +35,8 @@ parser.add_argument("--out",
required=True,
metavar="REQUIREMENTS")
+parser.add_argument("--report")
+
args = parser.parse_args()
-work(Path(args.in_path), Path(args.out))
+work(Path(args.in_path), Path(args.out), Path(args.report))
diff --git a/src/ee/tools/templates/build.ninja.j2 b/src/ee/tools/templates/build.ninja.j2
index 0706b11..6ff4e0a 100644
--- a/src/ee/tools/templates/build.ninja.j2
+++ b/src/ee/tools/templates/build.ninja.j2
@@ -32,7 +32,7 @@ rule part-apply-function
rule part-find-requirements
description = part-find-requirements
- command = $ee part-find-requirements --in $in --out $out
+ command = $ee part-find-requirements --in $in --out $out $report
rule part-validate-parts
command = $ee part-validate-parts --in $in --out $out
@@ -88,7 +88,9 @@ build ee/sch.xml: part-apply-function ee/kicad-sch.xml
build $report_dir/part-validate-parts.rst: part-validate-parts ee/sch.xml
{%- set reports=reports+["$report_dir/part-validate-parts.rst"] %}
-build ee/requirements.xml: part-find-requirements ee/sch.xml
+build ee/requirements.xml | $report_dir/requirements.rst: part-find-requirements ee/sch.xml
+ report = --report $report_dir/requirements.rst
+{%- set reports=reports+["$report_dir/requirements.rst"] %}
{% for s in distributors %}
{%- set cfg = project.cfg["supplier:" + s] if "supplier:" + s in project.cfg else None %}
@@ -97,7 +99,7 @@ build ee/{{ s }}/pn-part-search-list.xml: pn-part-search-list ee/sch.xml
supplier = {{ s }}
build ee/{{ s }}/downloaded.xml | ee/{{ s }}/downloaded.rst: {{ s }}-search-parts ee/{{ s }}/pn-part-search-list.xml
-{%- set reports=reports+["ee/" + s + "/downloaded.rst"] %}
+{%- set reports=reports+["$report_dir/" + s + "/downloaded.rst"] %}
build ee/{{ s }}/parts.xml: part-apply-function ee/{{ s }}/downloaded.xml
execution = {{ s }}