aboutsummaryrefslogtreecommitdiff
path: root/src/ee/supplier
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-03-28 16:38:50 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2019-03-28 16:43:14 +0100
commitfa85d46af0b91477cf354947df628af0dc0d2800 (patch)
treeb18b775d232560f57eaeb3f43d0861b98201d4ef /src/ee/supplier
parent52401b170d8f1c9deaa153acca76e7d6060a06df (diff)
downloadee-python-fa85d46af0b91477cf354947df628af0dc0d2800.tar.gz
ee-python-fa85d46af0b91477cf354947df628af0dc0d2800.tar.bz2
ee-python-fa85d46af0b91477cf354947df628af0dc0d2800.tar.xz
ee-python-fa85d46af0b91477cf354947df628af0dc0d2800.zip
ee.xsd:
o Renaming <part-uri> to <part-reference>. o Adding <supplier> on <part>, removing from <supplier-part-number>. A part can have exactly one part. create-order: o Creating anonymous part objects, with two references, one schematic reference and one part-uri reference to the selected part. o Redoing how the order is calculated with the new ObjDb structure. ee.part.Part: o Absorbing bom_file_utils into Part. Much better wrapper object around the xml goop.
Diffstat (limited to 'src/ee/supplier')
-rw-r--r--src/ee/supplier/seeed.py22
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)