aboutsummaryrefslogtreecommitdiff
path: root/src/ee/kicad
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-05-15 22:08:37 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-05-24 07:57:00 +0200
commit4afac7dc4c743284e5243428f00928aa7eaacfdc (patch)
treed2e65dbced03e310e15509a239eb096f41d047f4 /src/ee/kicad
parentd8b6719c628c7dfb4537ad2303c016884e9312f3 (diff)
downloadee-python-4afac7dc4c743284e5243428f00928aa7eaacfdc.tar.gz
ee-python-4afac7dc4c743284e5243428f00928aa7eaacfdc.tar.bz2
ee-python-4afac7dc4c743284e5243428f00928aa7eaacfdc.tar.xz
ee-python-4afac7dc4c743284e5243428f00928aa7eaacfdc.zip
ee.project: Making sure all projects have an UUID.
kicad-make-bom: Using the project's UUID to generate an URL for all parts.
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)