aboutsummaryrefslogtreecommitdiff
path: root/src/ee/digikey
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/digikey')
-rw-r--r--src/ee/digikey/search_parts.py20
1 files changed, 8 insertions, 12 deletions
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":