diff options
Diffstat (limited to 'src/ee/digikey')
-rw-r--r-- | src/ee/digikey/bom.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/ee/digikey/bom.py b/src/ee/digikey/bom.py index 398e03b..cb02f05 100644 --- a/src/ee/digikey/bom.py +++ b/src/ee/digikey/bom.py @@ -1,4 +1,5 @@ import csv +from math import ceil from pathlib import Path from typing import List @@ -7,18 +8,22 @@ 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): +def create_bom(bom_path: Path, part_files: List[Path], out_path: Path, allow_incomplete, quantity: float): 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) + bom = generate_bom(allow_incomplete, bom_parts, supplier_parts) - if lines is None: + if bom 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)]) + w.writerow(["Digi-Key Part Number", "Quantity", "Reference Designator"]) + + for line in bom.lines: + line = [ + line.part.get_exactly_one_spn().valueProp, + int(ceil(len(line.refs) * quantity)), + join_refs(line.refs)] + w.writerow([str(cell) for cell in line]) |