aboutsummaryrefslogtreecommitdiff
path: root/src/ee/project
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-04-14 19:41:30 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-04-14 19:41:30 +0200
commit37e4be24129b6980e3e9fced7345d4a596af3d58 (patch)
tree3443f320e6fd77558786fb022cb78b5babcc1985 /src/ee/project
parent791cd8213214feb7af77e434ee260e48984086fb (diff)
downloadee-python-37e4be24129b6980e3e9fced7345d4a596af3d58.tar.gz
ee-python-37e4be24129b6980e3e9fced7345d4a596af3d58.tar.bz2
ee-python-37e4be24129b6980e3e9fced7345d4a596af3d58.tar.xz
ee-python-37e4be24129b6980e3e9fced7345d4a596af3d58.zip
digikey:
o More flexibility, making room for the multiple digikey stores. o Removing URLs from core code. new tools: split_parts_by_supplier.
Diffstat (limited to 'src/ee/project')
-rw-r--r--src/ee/project/__init__.py15
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