diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2019-05-23 21:08:36 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2019-05-26 21:55:41 +0200 |
commit | 1699cca793c6a8ebc00942557b6764fff6739044 (patch) | |
tree | ee8162390db5a7607298fe5f40841bb131b60542 /src/ee/tools/part_find_requirements.py | |
parent | 4afac7dc4c743284e5243428f00928aa7eaacfdc (diff) | |
download | ee-python-1699cca793c6a8ebc00942557b6764fff6739044.tar.gz ee-python-1699cca793c6a8ebc00942557b6764fff6739044.tar.bz2 ee-python-1699cca793c6a8ebc00942557b6764fff6739044.tar.xz ee-python-1699cca793c6a8ebc00942557b6764fff6739044.zip |
part-find-requirements: wip
Diffstat (limited to 'src/ee/tools/part_find_requirements.py')
-rw-r--r-- | src/ee/tools/part_find_requirements.py | 29 |
1 files changed, 16 insertions, 13 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)) |