aboutsummaryrefslogtreecommitdiff
path: root/src/ee/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/tools')
-rw-r--r--src/ee/tools/digikey_download_facts.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/ee/tools/digikey_download_facts.py b/src/ee/tools/digikey_download_facts.py
index 9842c40..cc75f74 100644
--- a/src/ee/tools/digikey_download_facts.py
+++ b/src/ee/tools/digikey_download_facts.py
@@ -97,14 +97,12 @@ for q in queries:
if len(viable_products):
# Pick the first one, should be as good as any
- part_number = viable_products[0].part_number
+ part_number = sorted(viable_products, key=lambda p: p.part_number)[0].part_number
log.info("Got many hits for term '{}', will use {} for downloading attributes.".format(q.query, part_number))
todos.append(part_number)
else:
- for k, g in hits:
- log.info("Got many results with many parts: {}: {}".format(k, list(g)))
- on_product(list(g)[0])
+ log.warn("Got many results: {}".format(", ".join([p.part_number for p in response.products])))
elif response.response_type == SearchResponseTypes.TOO_MANY:
log.warn("Too many results ({}), select a category first".format(response.count))
elif response.response_type == SearchResponseTypes.NO_MATCHES:
@@ -114,7 +112,7 @@ for q in queries:
response = client.search(part_number)
if response.response_type == SearchResponseTypes.SINGLE:
- p = response.products[0]
+ p = sorted(response.products, key=lambda p: p.part_number)[0]
log.info("Downloaded {}".format(p.mpn))
on_product(p)
else: