diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2019-03-28 16:38:50 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2019-03-28 16:43:14 +0100 |
commit | fa85d46af0b91477cf354947df628af0dc0d2800 (patch) | |
tree | b18b775d232560f57eaeb3f43d0861b98201d4ef /src/ee/project/__init__.py | |
parent | 52401b170d8f1c9deaa153acca76e7d6060a06df (diff) | |
download | ee-python-fa85d46af0b91477cf354947df628af0dc0d2800.tar.gz ee-python-fa85d46af0b91477cf354947df628af0dc0d2800.tar.bz2 ee-python-fa85d46af0b91477cf354947df628af0dc0d2800.tar.xz ee-python-fa85d46af0b91477cf354947df628af0dc0d2800.zip |
ee.xsd:
o Renaming <part-uri> to <part-reference>.
o Adding <supplier> on <part>, removing from <supplier-part-number>. A
part can have exactly one part.
create-order:
o Creating anonymous part objects, with two references, one schematic
reference and one part-uri reference to the selected part.
o Redoing how the order is calculated with the new ObjDb structure.
ee.part.Part:
o Absorbing bom_file_utils into Part. Much better wrapper object around
the xml goop.
Diffstat (limited to 'src/ee/project/__init__.py')
-rw-r--r-- | src/ee/project/__init__.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/ee/project/__init__.py b/src/ee/project/__init__.py index 6851256..bca9984 100644 --- a/src/ee/project/__init__.py +++ b/src/ee/project/__init__.py @@ -1,7 +1,9 @@ import configparser from pathlib import Path +from ee import EeException from ee.tools import mk_parents +from ee.xml.uris import DIGIKEY_URI def load_config(project_dir: Path) -> configparser.ConfigParser: @@ -17,6 +19,12 @@ def load_config(project_dir: Path) -> configparser.ConfigParser: return config +class SupplierDescriptor(object): + def __init__(self, key: str, uri: str): + self.key = key + self.uri = uri + + class Project(object): def __init__(self, project_dir: Path, cfg: configparser.ConfigParser): self.report_dir = project_dir / "ee" / "reports" @@ -24,6 +32,15 @@ class Project(object): self.project_dir = project_dir self._cfg = cfg + # TODO: read from config + self._suppliers = [SupplierDescriptor("digikey", DIGIKEY_URI)] + + def get_supplier_by_key(self, key) -> SupplierDescriptor: + sd = next((s for s in self._suppliers if s.key == key), None) + if sd: + return sd + raise EeException("No such supplier configured: {}".format(key)) + @property def cfg(self): return self._cfg |