From fa85d46af0b91477cf354947df628af0dc0d2800 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 28 Mar 2019 16:38:50 +0100 Subject: ee.xsd: o Renaming to . o Adding on , removing from . 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. --- src/ee/project/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/ee/project/__init__.py') 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 -- cgit v1.2.3