import argparse from pathlib import Path from ee.part import requirement, Part, load_db def work(in_path: Path, out_path: Path, report_path: Path): in_parts = load_db(in_path) requirements = [] for xml in in_parts.iterparts(): part = Part(xml) analysis = requirement.analyze_requirements(part) requirements.append(analysis) 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 a.requirements: print("* {}".format(str(r)), file=f) print("", file=f) parser = argparse.ArgumentParser() parser.add_argument("--in", dest="in_path", required=True, metavar="PART DB") parser.add_argument("--out", required=True, metavar="REQUIREMENTS") parser.add_argument("--report") args = parser.parse_args() work(Path(args.in_path), Path(args.out), Path(args.report))