support optional data in upc.py
This commit is contained in:
parent
f751d85824
commit
b8145dd60d
1 changed files with 19 additions and 11 deletions
|
@ -26,20 +26,28 @@ class Module(object):
|
||||||
return
|
return
|
||||||
item = page["items"][0]
|
item = page["items"][0]
|
||||||
|
|
||||||
brand = item["brand"]
|
brand = item.get("brand", None)
|
||||||
|
brand = "" if not brand else "%s - " % brand
|
||||||
title = item["title"]
|
title = item["title"]
|
||||||
description = item["description"]
|
description = item.get("description", None)
|
||||||
|
description = " " if not description else ": %s " % description
|
||||||
|
|
||||||
weight = item["weight"]
|
weight = item.get("weight", None)
|
||||||
size = item["dimension"]
|
weight = weight or "unknown"
|
||||||
|
size = item.get("dimension", None)
|
||||||
|
size = size or "unknown"
|
||||||
|
|
||||||
currency = item["currency"]
|
currency = item.get("currency", None)
|
||||||
lowest_price = item["lowest_recorded_price"]
|
lowest_price = item.get("lowest_recorded_price", None)
|
||||||
highest_price = item["highest_recorded_price"]
|
highest_price = item.get("highest_recorded_price", None)
|
||||||
|
|
||||||
event["stdout"].write("%s - %s: %s (weight: %s"
|
pricing = "price: unknown"
|
||||||
", size: %s, price: %s to %s %s)" % (
|
if lowest_price and highest_price and currency:
|
||||||
brand, title, description, weight, size,
|
pricing = "price: %s to %s %s" % (
|
||||||
lowest_price, highest_price, currency))
|
lowest_price, highest_price, currency)
|
||||||
|
|
||||||
|
event["stdout"].write("%s%s%s(weight: %s"
|
||||||
|
", size: %s, price: %s)" % (
|
||||||
|
brand, title, description, weight, size, pricing))
|
||||||
else:
|
else:
|
||||||
event["stderr"].write("Failed to load results")
|
event["stderr"].write("Failed to load results")
|
||||||
|
|
Loading…
Reference in a new issue