aboutsummaryrefslogtreecommitdiff
path: root/src/ee/digikey
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/digikey')
-rw-r--r--src/ee/digikey/normalize_facts.py14
-rw-r--r--src/ee/digikey/search_parts.py32
2 files changed, 23 insertions, 23 deletions
diff --git a/src/ee/digikey/normalize_facts.py b/src/ee/digikey/normalize_facts.py
index 62aef0d..91e8c07 100644
--- a/src/ee/digikey/normalize_facts.py
+++ b/src/ee/digikey/normalize_facts.py
@@ -4,13 +4,13 @@ from typing import List, Tuple, Union, Mapping, Callable, Any
from ee import EeVal, EeException
from ee.part import PartDb, load_db, save_db
-from ee.xml import bomFile, uris
+from ee.xml import types, uris
__all__ = ["normalize_facts"]
# TODO: this should be moved to a generic normalizer
-def handle_tolerance(tolerance: bomFile.Fact, capacitance: bomFile.Fact) -> List[bomFile.Fact]:
+def handle_tolerance(tolerance: types.Fact, capacitance: types.Fact) -> List[types.Fact]:
cap_value = float(EeVal.parse(capacitance.valueProp))
s = tolerance.valueProp
@@ -62,7 +62,7 @@ def handle_tolerance(tolerance: bomFile.Fact, capacitance: bomFile.Fact) -> List
if low_pct and low_pct == high_pct:
facts.append(("tolerance-percent", "Tolerance (±%)", low_pct))
- return [bomFile.Fact(key=uris.make_fact_key(key), label=label, value=str(value)) for key, label, value in facts]
+ return [types.Fact(key=uris.make_fact_key(key), label=label, value=str(value)) for key, label, value in facts]
def re_parser(pattern, kis: List[Tuple[str, int]]):
@@ -119,12 +119,12 @@ def normalize_facts(in_dir: Path, out_dir: Path):
in_db = load_db(in_dir)
out_parts = PartDb()
- for part in in_db.iterparts(): # type: bomFile.Part
- fact_list: bomFile.FactList = part.factsProp
+ for part in in_db.iterparts(): # type: types.Part
+ fact_list: types.FactList = part.factsProp
if fact_list is None:
continue
- in_facts: List[bomFile.Fact] = fact_list.factProp
+ in_facts: List[types.Fact] = fact_list.factProp
out_facts = []
for f in in_facts:
@@ -145,7 +145,7 @@ def normalize_facts(in_dir: Path, out_dir: Path):
results = res
else:
results = [res]
- facts = [bomFile.Fact(key=uris.make_fact_key(key), value=value) for key, value in results]
+ facts = [types.Fact(key=uris.make_fact_key(key), value=value) for key, value in results]
out_facts.extend(facts)
if len(out_facts) == 0:
diff --git a/src/ee/digikey/search_parts.py b/src/ee/digikey/search_parts.py
index 61c5c1b..4203624 100644
--- a/src/ee/digikey/search_parts.py
+++ b/src/ee/digikey/search_parts.py
@@ -3,37 +3,37 @@ 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 import types, bom_file_utils
from ee.xml.uris import DIGIKEY_URI, make_digikey_fact_key
__all__ = ["search_parts"]
-def resolved(p: DigikeyProduct) -> bomFile.Part:
- part = bomFile.Part(id=p.part_number,
- distributor_info=bomFile.DistributorInfo(),
- facts=bomFile.FactList(),
- part_numbers=bomFile.PartNumberList())
+def resolved(p: DigikeyProduct) -> types.Part:
+ part = types.Part(id=p.part_number,
+ distributor_info=types.DistributorInfo(),
+ facts=types.FactList(),
+ part_numbers=types.PartNumberList())
part.distributor_infoProp.stateProp = "resolved"
part_numbers = part.part_numbersProp.part_numberProp
- part_numbers.append(bomFile.PartNumber(value=p.part_number, distributor=DIGIKEY_URI))
+ part_numbers.append(types.PartNumber(value=p.part_number, distributor=DIGIKEY_URI))
if p.mpn:
- part_numbers.append(bomFile.PartNumber(value=p.mpn))
- facts: List[bomFile.Fact] = part.factsProp.factProp
+ part_numbers.append(types.PartNumber(value=p.mpn))
+ facts: List[types.Fact] = part.factsProp.factProp
for a in p.attributes:
key = make_digikey_fact_key(a.attribute_type.id)
- facts.append(bomFile.Fact(key=key, label=a.attribute_type.label, value=a.value))
+ facts.append(types.Fact(key=key, label=a.attribute_type.label, value=a.value))
if len(p.price_breaks):
- part.price_breaksProp = bomFile.PriceBreakList()
+ part.price_breaksProp = types.PriceBreakList()
- price_breaks: List[bomFile.PriceBreak] = part.price_breaksProp.price_break
+ price_breaks: List[types.PriceBreak] = part.price_breaksProp.price_break
for pb in p.price_breaks:
- amount = bomFile.Amount(value=str(pb.per_piece_price.amount), currency=pb.per_piece_price.currency)
- price_breaks.append(bomFile.PriceBreak(pb.quantity, amount=amount))
+ amount = types.Amount(value=str(pb.per_piece_price.amount), currency=pb.per_piece_price.currency)
+ price_breaks.append(types.PriceBreak(pb.quantity, amount=amount))
return part
@@ -65,8 +65,8 @@ def search_parts(in_dir: Path, out_dir: Path, cache_dir: Path, force_refresh: bo
continue
out_id = query
- out_part = bomFile.Part(id=out_id,
- distributor_info=bomFile.DistributorInfo(),
+ out_part = types.Part(id=out_id,
+ distributor_info=types.DistributorInfo(),
part_numbers=part.part_numbersProp)
di = out_part.distributor_infoProp