diff options
Diffstat (limited to 'src/ee/project')
-rw-r--r-- | src/ee/project/__init__.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ee/project/__init__.py b/src/ee/project/__init__.py index 24635ee..0857e7c 100644 --- a/src/ee/project/__init__.py +++ b/src/ee/project/__init__.py @@ -2,8 +2,8 @@ import configparser from pathlib import Path from ee import EeException +from ee.digikey import DigikeyStore from ee.tools import mk_parents -from ee.xml.uris import DIGIKEY_URI def load_config(project_dir: Path) -> configparser.ConfigParser: @@ -20,9 +20,10 @@ def load_config(project_dir: Path) -> configparser.ConfigParser: class SupplierDescriptor(object): - def __init__(self, key: str, uri: str): + def __init__(self, key: str, uri: str, name: str): self.key = key self.uri = uri + self.name = name class Project(object): @@ -34,7 +35,9 @@ class Project(object): self._cfg = cfg # TODO: read from config - self._suppliers = [SupplierDescriptor("digikey", DIGIKEY_URI)] + self._suppliers = [] + digikey_store = DigikeyStore.from_store_code("us") + self._suppliers.append(SupplierDescriptor("digikey", digikey_store.url, "Digikey")) def get_supplier_by_key(self, key) -> SupplierDescriptor: sd = next((s for s in self._suppliers if s.key == key), None) @@ -42,6 +45,12 @@ class Project(object): return sd raise EeException("No such supplier configured: {}".format(key)) + def get_supplier_by_uri(self, uri) -> SupplierDescriptor: + sd = next((s for s in self._suppliers if s.uri == uri), None) + if sd: + return sd + raise EeException("No such supplier configured: {}".format(uri)) + @property def cfg(self): return self._cfg |