From f14a40a4f80275daceeb73f944e1aa1f84d16c79 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 26 Feb 2019 23:14:22 +0100 Subject: o Removing digikey specific DistributionInfo element. Can be generic. --- src/ee/digikey/search_parts.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/ee/digikey') diff --git a/src/ee/digikey/search_parts.py b/src/ee/digikey/search_parts.py index 62bb4ee..cad611b 100644 --- a/src/ee/digikey/search_parts.py +++ b/src/ee/digikey/search_parts.py @@ -4,23 +4,21 @@ from typing import List from ee.digikey import Digikey, DigikeyParser, DigikeyClient, SearchResponseTypes, DigikeyProduct from ee.part import PartDb, load_db, save_db from ee.xml import bomFile, bom_file_utils -from ee.xml.bomFile import DigikeyDistributorInfo -from ee.xml.uris import DIGIKEY_URI +from ee.xml.uris import DIGIKEY_URI, make_digikey_fact_key __all__ = ["search_parts"] -def resolved(di: DigikeyDistributorInfo, part: bomFile.Part, p: DigikeyProduct): +def resolved(di: bomFile.DistributorInfo, part: bomFile.Part, p: DigikeyProduct): di.stateProp = "resolved" - fact_set = bom_file_utils.find_fact_set(part, DIGIKEY_URI, create=True) - # Remove the old list - fact_set.factsProp = bomFile.FactList() - facts: List[bomFile.Fact] = fact_set.factsProp.factProp + part.factsProp = bomFile.FactList() + facts: List[bomFile.Fact] = part.factsProp.factProp for a in p.attributes: - facts.append(bomFile.Fact(key=a.attribute_type.id, label=a.attribute_type.label, value=a.value)) + key = make_digikey_fact_key(a.attribute_type.id) + facts.append(bomFile.Fact(key=key, label=a.attribute_type.label, value=a.value)) def search_parts(in_dir: Path, out_dir: Path, cache_dir: Path, force_refresh: bool): @@ -49,12 +47,10 @@ def search_parts(in_dir: Path, out_dir: Path, cache_dir: Path, force_refresh: bo print("could not find pn or dpn: part.id={}".format(part.idProp)) continue - di = part.distributor_infoProp # type: DigikeyDistributorInfo + di = part.distributor_infoProp # type: bomFile.DistributorInfo if di is None: - di = bomFile.DigikeyDistributorInfo() - di.extensiontype_ = "DigikeyDistributorInfo" - di.original_tagname_ = "distributor-info" + di = bomFile.DistributorInfo() part.distributor_infoProp = di if force_refresh or di.stateProp != "resolved": -- cgit v1.2.3