aboutsummaryrefslogtreecommitdiff
path: root/src/ee/project
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/project
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/project')
-rw-r--r--src/ee/project/__init__.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ee/project/__init__.py b/src/ee/project/__init__.py
index 0857e7c..6c04c07 100644
--- a/src/ee/project/__init__.py
+++ b/src/ee/project/__init__.py
@@ -1,4 +1,5 @@
import configparser
+import uuid
from pathlib import Path
from ee import EeException
@@ -34,6 +35,13 @@ class Project(object):
self.project_dir = project_dir
self._cfg = cfg
+ if "project" not in cfg:
+ cfg.add_section("project")
+
+ project = cfg["project"]
+ if "uuid" not in project:
+ project["uuid"] = str(uuid.uuid4())
+
# TODO: read from config
self._suppliers = []
digikey_store = DigikeyStore.from_store_code("us")
@@ -55,6 +63,10 @@ class Project(object):
def cfg(self):
return self._cfg
+ @property
+ def uuid(self):
+ return uuid.UUID(hex=self._cfg["project"]["uuid"])
+
@classmethod
def load(cls):
project_dir = Path(".")