aboutsummaryrefslogtreecommitdiff
path: root/src/ee/kicad
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-03-15 07:58:06 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2019-03-15 08:30:07 +0100
commitb67aa2b41247991e361dec0963670b4e5108410a (patch)
tree67591b0f4cc6e767d0097c1afc3f08ad40ee19ea /src/ee/kicad
parent8d17fb5bc4b0dae0758e01a44d77d87acf2e686a (diff)
downloadee-python-b67aa2b41247991e361dec0963670b4e5108410a.tar.gz
ee-python-b67aa2b41247991e361dec0963670b4e5108410a.tar.bz2
ee-python-b67aa2b41247991e361dec0963670b4e5108410a.tar.xz
ee-python-b67aa2b41247991e361dec0963670b4e5108410a.zip
o Merging XSD files into one.
Diffstat (limited to 'src/ee/kicad')
-rw-r--r--src/ee/kicad/make_bom.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/ee/kicad/make_bom.py b/src/ee/kicad/make_bom.py
index 00e9ae3..7dd5532 100644
--- a/src/ee/kicad/make_bom.py
+++ b/src/ee/kicad/make_bom.py
@@ -9,7 +9,7 @@ from ee.kicad.model import Component
from ee.kicad.read_schematic import read_schematics
from ee.kicad.to_bom import to_bom, to_bom_xml
from ee.part import PartDb, save_db
-from ee.xml import bomFile, uris
+from ee.xml import types, uris
__all__ = [
"StrategyCallable",
@@ -21,23 +21,23 @@ __all__ = [
"make_bom",
]
-StrategyCallable = Callable[[Component, bomFile.Part], Optional[bomFile.Part]]
+StrategyCallable = Callable[[Component, types.Part], Optional[types.Part]]
-def apply_strategies(c: Component, part: bomFile.Part, strategies: List[StrategyCallable]):
+def apply_strategies(c: Component, part: types.Part, strategies: List[StrategyCallable]):
for strategy in strategies:
part = strategy(c, part)
if part is None:
return
- if not isinstance(part, bomFile.Part):
- raise EeException("Values returned from strategy must be a bomFile.Part, got {}".format(type(part)))
+ if not isinstance(part, types.Part):
+ raise EeException("Values returned from strategy must be a types.Part, got {}".format(type(part)))
return part
-def part_type_strategy(component: Component, part: bomFile.Part) -> bomFile.Part:
+def part_type_strategy(component: Component, part: types.Part) -> types.Part:
fp = component.footprint
if fp is None:
return part
@@ -58,23 +58,23 @@ def part_type_strategy(component: Component, part: bomFile.Part) -> bomFile.Part
return part
-def mpn_strategy(component: Component, part: bomFile.Part) -> bomFile.Part:
+def mpn_strategy(component: Component, part: types.Part) -> types.Part:
mpn = component.get_field("mpn")
if mpn is not None:
- pn = bomFile.PartNumber(value=mpn.value)
+ pn = types.PartNumber(value=mpn.value)
part.part_numbersProp.add_part_number(pn)
return part
def dpn_strategy_factory(dpn_mappings: Mapping[str, str]) -> StrategyCallable:
- def dpn_strategy(component: Component, part: bomFile.Part) -> bomFile.Part:
+ def dpn_strategy(component: Component, part: types.Part) -> types.Part:
for field_name, distributor in dpn_mappings:
s = component.get_field(field_name)
if s is None:
continue
- pn = bomFile.PartNumber(value=s.value, distributor=distributor)
+ pn = types.PartNumber(value=s.value, distributor=distributor)
part.part_numbersProp.add_part_number(pn)
return part
@@ -91,10 +91,10 @@ class MakeBomStrategy():
dpn_strategy_factory(self.dpn_mappings),
]
- def process_part(self, component: Component, part: bomFile.Part):
+ def process_part(self, component: Component, part: types.Part):
return self.default_process_part(component, part)
- def default_process_part(self, component: Component, part: bomFile.Part):
+ def default_process_part(self, component: Component, part: types.Part):
return apply_strategies(component, part, self.default_strategies)
@@ -111,9 +111,9 @@ def work(sch, out: Path, strategy: MakeBomStrategy, new_mode, pretty):
parts = PartDb()
components = to_bom(sch)
for c in components:
- part = bomFile.Part(id=c.ref)
+ part = types.Part(id=c.ref)
part.schema_reference = c.ref
- part.part_numbersProp = bomFile.PartNumberList()
+ part.part_numbersProp = types.PartNumberList()
part = strategy.process_part(c, part)