diff options
Diffstat (limited to 'src/ee/digikey/search_parts.py')
-rw-r--r-- | src/ee/digikey/search_parts.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ee/digikey/search_parts.py b/src/ee/digikey/search_parts.py index 3d271d5..358266a 100644 --- a/src/ee/digikey/search_parts.py +++ b/src/ee/digikey/search_parts.py @@ -13,9 +13,19 @@ def resolved(p: DigikeyProduct) -> types.Part: # TODO: fix uri part = types.Part(uri="https://digikey.com/pn#{}".format(p.part_number), distributor_info=types.DistributorInfo(), + links=types.LinkList(), facts=types.FactList(), references=types.ReferencesList()) part.distributor_infoProp.stateProp = "resolved" + links = part.linksProp.link + + if p.url: + links.append(types.Link(url=p.url, relation="canonical", media_type="text/html")) + + for d in p.documents: + title = "{}: {}".format(d.kind, d.title) + links.append(types.Link(url=d.url, relation="http://purl.org/ee/link-relation#documentation", + media_type="text/html", title=title)) supplier_part_numbers = part.referencesProp.supplier_part_numberProp supplier_part_numbers.append(types.SupplierPartNumber(value=p.part_number, supplier=DIGIKEY_URI)) @@ -48,7 +58,8 @@ def search_parts(in_path: Path, out_path: Path, cache_dir: Path): client = DigikeyClient(cache_dir) for part in in_db.iterparts(): - dpn = next((p.valueProp for p in bom_file_utils.supplier_part_numbers(part) if p.supplierProp == DIGIKEY_URI), None) + dpn = next((p.valueProp for p in bom_file_utils.supplier_part_numbers(part) + if p.supplierProp == DIGIKEY_URI), None) mpn = next((p.valueProp for p in bom_file_utils.part_numbers(part)), None) is_mpn = query = None |