aboutsummaryrefslogtreecommitdiff
path: root/src/ee/kicad
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-03-15 14:55:15 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2019-03-15 14:55:15 +0100
commit237a6faa8a23826e68bbc00bc107b2d6f97235d0 (patch)
treefe1a6a6b1a4ed991a6eacd9ec6960325db3f9e4f /src/ee/kicad
parent3523190bb7ca1c38caea3a1aae51062d22e56b09 (diff)
downloadee-python-237a6faa8a23826e68bbc00bc107b2d6f97235d0.tar.gz
ee-python-237a6faa8a23826e68bbc00bc107b2d6f97235d0.tar.bz2
ee-python-237a6faa8a23826e68bbc00bc107b2d6f97235d0.tar.xz
ee-python-237a6faa8a23826e68bbc00bc107b2d6f97235d0.zip
Refactoring:
o Renaming part.id to part.uri. Changing to URIs and use that as an identifier if the part is known. Schematic part does not have an URI. o Merging <schema-reference> and <part-numbers> into <references> o Creating <part-uri> as a possible <reference>. Used by order to point to other parts.
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)