diff options
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 |