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.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/ee/kicad/make_bom.py b/src/ee/kicad/make_bom.py
index 5242832..2faae31 100644
--- a/src/ee/kicad/make_bom.py
+++ b/src/ee/kicad/make_bom.py
@@ -1,4 +1,6 @@
+import uuid
from pathlib import Path
+from uuid import UUID
from xml.dom import minidom
from xml.etree import ElementTree
@@ -13,7 +15,7 @@ __all__ = [
]
-def work(sch, out: Path, new_mode, pretty):
+def work(sch, out: Path, project_uuid: UUID, new_mode, pretty):
def strip(s):
s = (s or "").strip()
@@ -30,8 +32,16 @@ def work(sch, out: Path, new_mode, pretty):
else:
parts = PartDb()
components = to_bom(sch, require_ref=False)
+ count = 0
for c in components:
- xml = types.Part()
+ count = count + 1
+
+ if c.has_ref_num:
+ uri_ref = c.ref
+ else:
+ uri_ref = str(uuid.uuid5(uuid.NAMESPACE_DNS, str(count)))
+
+ xml = types.Part(uri=uris.make_schematic_part_uri(project_uuid, uri_ref))
part = Part(xml)
if c.has_ref_num:
@@ -64,7 +74,7 @@ def work(sch, out: Path, new_mode, pretty):
save_db(out, parts)
-def make_bom(sch_file: Path, out_dir: Path, new_mode: bool, pretty: bool):
+def make_bom(sch_file: Path, out_dir: Path, project_uuid: UUID, new_mode: bool, pretty: bool):
sch = read_schematics(str(sch_file))
- work(sch, out_dir, new_mode, pretty)
+ work(sch, out_dir, project_uuid, new_mode, pretty)