From 2e2956823c9cd02c766b296cbcbea9130bd07b36 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 28 May 2019 09:46:41 +0200 Subject: digikey: Better search when getting multiple results back. Instead of doing a new search with the selected digikey part number, do a direct lookup with the product's URL instead. This ensures that we always get a match and don't get confused when multiple part numbers are returned. --- src/ee/tools/digikey_download_facts.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ee/tools') diff --git a/src/ee/tools/digikey_download_facts.py b/src/ee/tools/digikey_download_facts.py index 5cfdba7..d7ecce5 100644 --- a/src/ee/tools/digikey_download_facts.py +++ b/src/ee/tools/digikey_download_facts.py @@ -1,3 +1,6 @@ +if True: + raise Exception("This module is deprecated.") + import argparse from functools import total_ordering @@ -5,9 +8,6 @@ import ee.digikey as dk from ee.digikey import SearchResponseTypes, DigikeyProduct from ee.tools import log -if True: - raise Exception("This module is deprecated.") - @total_ordering class Query(object): @@ -83,7 +83,7 @@ for q in queries: continue log.info("Searching for {}".format(p)) - response = parser.parse_string(client.search(p)) + response = parser.parse_string(client.baseurl, client.search(p)) todos = [] @@ -113,7 +113,7 @@ for q in queries: log.warn("Part not found") for part_number in todos: - response = parser.parse_string(client.search(part_number)) + response = parser.parse_string(client.baseurl, client.search(part_number)) if response.response_type == SearchResponseTypes.SINGLE: p = sorted(response.products, key=lambda p: p.part_number)[0] -- cgit v1.2.3