aboutsummaryrefslogtreecommitdiff
path: root/src/ee/kicad
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/kicad')
-rw-r--r--src/ee/kicad/make_bom.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/ee/kicad/make_bom.py b/src/ee/kicad/make_bom.py
index 7dd5532..0a8f4bb 100644
--- a/src/ee/kicad/make_bom.py
+++ b/src/ee/kicad/make_bom.py
@@ -62,7 +62,7 @@ def mpn_strategy(component: Component, part: types.Part) -> types.Part:
mpn = component.get_field("mpn")
if mpn is not None:
pn = types.PartNumber(value=mpn.value)
- part.part_numbersProp.add_part_number(pn)
+ part.referencesProp.add_part_number(pn)
return part
@@ -74,8 +74,8 @@ def dpn_strategy_factory(dpn_mappings: Mapping[str, str]) -> StrategyCallable:
if s is None:
continue
- pn = types.PartNumber(value=s.value, distributor=distributor)
- part.part_numbersProp.add_part_number(pn)
+ pn = types.SupplierPartNumber(value=s.value, supplier=distributor)
+ part.referencesProp.add_part_number(pn)
return part
@@ -111,17 +111,22 @@ def work(sch, out: Path, strategy: MakeBomStrategy, new_mode, pretty):
parts = PartDb()
components = to_bom(sch)
for c in components:
- part = types.Part(id=c.ref)
- part.schema_reference = c.ref
- part.part_numbersProp = types.PartNumberList()
+ part = types.Part()
+ part.referencesProp = types.ReferencesList()
+ part.referencesProp.schematic_reference.append(types.SchematicReference(reference=c.ref))
part = strategy.process_part(c, part)
- if len(part.part_numbersProp.get_part_number()) == 0:
- part.part_numbersProp = None
+ if part is None:
+ continue
+
+ if len(part.referencesProp.schematic_reference) == 0 and \
+ len(part.referencesProp.part_number) == 0 and \
+ len(part.referencesProp.supplier_part_number) == 0:
+ # No need to dirty the xml with empty lists
+ part.referencesProp = None
- if part is not None:
- parts.add_entry(part, True)
+ parts.add_entry(part, True)
save_db(out, parts)