From b67aa2b41247991e361dec0963670b4e5108410a Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 15 Mar 2019 07:58:06 +0100 Subject: o Merging XSD files into one. --- src/ee/digikey/search_parts.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/ee/digikey/search_parts.py') 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 -- cgit v1.2.3