Add category field, update datasheet extracted fields
This commit is contained in:
19
run.py
19
run.py
@@ -169,29 +169,30 @@ def check_server():
|
||||
fs = cabledata["fullspecs"]
|
||||
tmp1 = {"part_number": cable_list[idx], "position": idx, "name": cable_list[idx], "brand": cabledata["brand"] }
|
||||
if "Product Overview" in fs and "Product Category" in fs["Product Overview"]:
|
||||
tmp1["short_description"] = fs["Product Overview"]["Product Category"]
|
||||
tmp1["category"] = fs["Product Overview"]["Product Category"]
|
||||
if "Product Overview" in fs and "Suitable Applications" in fs["Product Overview"]:
|
||||
if len(fs["Product Overview"]["Suitable Applications"]) == 0 or not isinstance(fs["Product Overview"]["Suitable Applications"], str):
|
||||
print(cable_list[idx], fs["Product Overview"]["Suitable Applications"])
|
||||
for key, value in fs["Product Overview"].items():
|
||||
#print(key,value)
|
||||
if len(value) > 5 and isinstance(value, str):
|
||||
tmp1["description"] = value
|
||||
tmp1["application"] = value
|
||||
elif len(key) > 15 and not isinstance(value, str):
|
||||
tmp1["description"] = key
|
||||
tmp1["application"] = key
|
||||
else:
|
||||
tmp1["description"] = fs["Product Overview"]["Suitable Applications"]
|
||||
tmp1["application"] = fs["Product Overview"]["Suitable Applications"]
|
||||
elif "Product Overview" in fs and "Suitable Applications:" in fs["Product Overview"]:
|
||||
if len(fs["Product Overview"]["Suitable Applications:"]) == 0 or not isinstance(fs["Product Overview"]["Suitable Applications:"], str):
|
||||
print(cable_list[idx], fs["Product Overview"]["Suitable Applications:"])
|
||||
for key, value in fs["Product Overview"].items():
|
||||
#print(key,value)
|
||||
if len(value) > 5 and isinstance(value, str):
|
||||
tmp1["description"] = value
|
||||
tmp1["application"] = value
|
||||
elif len(key) > 15 and not isinstance(value, str):
|
||||
tmp1["description"] = key
|
||||
tmp1["application"] = key
|
||||
else:
|
||||
tmp1["description"] = fs["Product Overview"]["Suitable Applications:"]
|
||||
tmp1["application"] = fs["Product Overview"]["Suitable Applications:"]
|
||||
|
||||
if "image" in cabledata:
|
||||
tmp1["image"] = cabledata["image"]
|
||||
if "description" in cabledata:
|
||||
@@ -200,7 +201,9 @@ def check_server():
|
||||
tmp1["short_description"] = cabledata["short_description"]
|
||||
if "application" in cabledata:
|
||||
tmp1["application"] = cabledata["application"]
|
||||
|
||||
if "category" in cabledata:
|
||||
tmp1["category"] = cabledata["category"]
|
||||
|
||||
tmp.append(tmp1)
|
||||
out = {"map": tmp}
|
||||
fprint(out)
|
||||
|
||||
Reference in New Issue
Block a user