import csv from pathlib import Path from typing import List from ee.part.bom import load_bom, check_bom, generate_bom, join_refs __all__ = ["create_bom"] def create_bom(bom_path: Path, part_files: List[Path], out_path: Path, allow_incomplete): bom_parts, supplier_parts = load_bom(bom_path, part_files) check_bom(bom_parts, supplier_parts) lines = generate_bom(allow_incomplete, bom_parts, supplier_parts) if lines is None: return with out_path.open("w") as f: w = csv.writer(f) w.writerow(["Quantity", "Digi-Key Part Number", "Customer Reference"]) for line in lines: w.writerows([str(len(line.refs)), line.part.get_exactly_one_spn().valueProp, join_refs(line.refs)])