aboutsummaryrefslogtreecommitdiff
path: root/src/ee/kicad
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/kicad')
-rw-r--r--src/ee/kicad/__init__.py3
-rw-r--r--src/ee/kicad/model.py9
-rw-r--r--src/ee/kicad/to_bom.py8
3 files changed, 17 insertions, 3 deletions
diff --git a/src/ee/kicad/__init__.py b/src/ee/kicad/__init__.py
index adf8ddd..5187a9c 100644
--- a/src/ee/kicad/__init__.py
+++ b/src/ee/kicad/__init__.py
@@ -2,7 +2,7 @@ from typing import Any
from ee import EeException
from ee.kicad.read_schematic import read_schematic
-from ee.kicad.to_bom import to_bom
+from ee.kicad.to_bom import to_bom, to_bom_xml
from .model import *
__all__ = [
@@ -12,6 +12,7 @@ __all__ = [
"Schematic",
"read_schematic",
"to_bom",
+ "to_bom_xml",
"to_pandas",
]
diff --git a/src/ee/kicad/model.py b/src/ee/kicad/model.py
index f112e72..b230f94 100644
--- a/src/ee/kicad/model.py
+++ b/src/ee/kicad/model.py
@@ -105,6 +105,10 @@ class Component(object):
return self.ref_type == "#PWR"
@property
+ def is_flg(self) -> bool:
+ return self.ref_type == "#FLG"
+
+ @property
def value(self):
return self._fields[1].value
@@ -120,6 +124,11 @@ class Component(object):
def named_fields(self):
return [f for f in self._fields if f.name]
+ def get_field(self, name) -> ComponentField:
+ for f in self.fields:
+ if name.lower() == f.name.lower():
+ return f
+
class Sheet(object):
def __init__(self):
diff --git a/src/ee/kicad/to_bom.py b/src/ee/kicad/to_bom.py
index d684486..ecab211 100644
--- a/src/ee/kicad/to_bom.py
+++ b/src/ee/kicad/to_bom.py
@@ -34,7 +34,11 @@ def comp(c: Component) -> Element:
return comp
-def to_bom(schematic: Schematic) -> Element:
+def to_bom(schematic: Schematic) -> Component:
+ return [c for c in sorted(schematic.components) if c.ref_type != "#PWR" and c.ref_type != "#FLG"]
+
+
+def to_bom_xml(schematic: Schematic) -> Element:
root = Element("export")
root.attrib["version"] = "D"
design = Element("design")
@@ -42,6 +46,6 @@ def to_bom(schematic: Schematic) -> Element:
components = Element("components")
root.append(components)
- [components.append(comp(c)) for c in sorted(schematic.components) if c.ref_type != "#PWR" and c.ref_type != "#FLG"]
+ [components.append(comp(c)) for c in to_bom(schematic)]
return root