aboutsummaryrefslogtreecommitdiff
path: root/src/ee/digikey
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-02-26 23:14:22 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2019-02-26 23:14:22 +0100
commitf14a40a4f80275daceeb73f944e1aa1f84d16c79 (patch)
tree9ce3cd2b8702214bc94ae3f38b568bf8bdd5eaa0 /src/ee/digikey
parent97c8bb9db96e27051f8746865f657408263db0b8 (diff)
downloadee-python-f14a40a4f80275daceeb73f944e1aa1f84d16c79.tar.gz
ee-python-f14a40a4f80275daceeb73f944e1aa1f84d16c79.tar.bz2
ee-python-f14a40a4f80275daceeb73f944e1aa1f84d16c79.tar.xz
ee-python-f14a40a4f80275daceeb73f944e1aa1f84d16c79.zip
o Removing digikey specific DistributionInfo element. Can be generic.
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":