diff options
Diffstat (limited to 'src/ee/supplier')
-rw-r--r-- | src/ee/supplier/seeed.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/ee/supplier/seeed.py b/src/ee/supplier/seeed.py index 2df2068..45cff44 100644 --- a/src/ee/supplier/seeed.py +++ b/src/ee/supplier/seeed.py @@ -9,7 +9,7 @@ import requests from selenium import webdriver import ee._utils -from ee.part import PartDb, save_db +from ee.part import Part, PartDb, save_db from ee.xml import types _title_re = re.compile(r"^([^(]*)\( *[0-9]* *\) *") @@ -113,13 +113,10 @@ def download_opls(out_dir: Path, cache_dir: Path): ladder_price = p["ladder_price"] - part = types.Part(references=types.ReferencesList(), price_breaks=types.PriceBreakList()) - part_numbers = part.referencesProp.part_numberProp - supplier_part_numbers = part.referencesProp.supplier_part_numberProp - pbs = part.price_breaksProp.price_breakProp + xml = types.Part(references=types.ReferencesList(), price_breaks=types.PriceBreakList()) + xml.supplierProp = supplier_uri - if desc: - part.descriptionProp = desc + xml.descriptionProp = desc uri_params = { "opl": opls_type, @@ -128,17 +125,18 @@ def download_opls(out_dir: Path, cache_dir: Path): uri_params["sku"] = sku if mpn: uri_params["mpn"] = mpn - part.uriProp = "http://purl.org/ee/supplier/seeed?{}".format(urlencode(uri_params)) + xml.uriProp = "http://purl.org/ee/supplier/seeed?{}".format(urlencode(uri_params)) + + part = Part(xml) if mpn: - part_numbers.append(types.PartNumber(mpn)) + part.add_mpn(mpn) if sku: - supplier_part_numbers.append(types.SupplierPartNumber(value=mpn, supplier=supplier_uri)) + part.add_spn(sku) for item in ladder_price: price = money.parse(item["price"], currency="USD") - amount = types.Amount(value=price.amount, currency=price.currency) - pbs.append(types.PriceBreak(quantity=item["qty"], amount=amount)) + part.add_price_break(item["qty"], price) db.add_entry(part, True) |