From 4afac7dc4c743284e5243428f00928aa7eaacfdc Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Wed, 15 May 2019 22:08:37 +0200 Subject: ee.project: Making sure all projects have an UUID. kicad-make-bom: Using the project's UUID to generate an URL for all parts. --- src/ee/project/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/ee/project') 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(".") -- cgit v1.2.3