aboutsummaryrefslogtreecommitdiff
path: root/src/ee/digikey
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/digikey')
-rw-r--r--src/ee/digikey/__init__.py7
-rw-r--r--src/ee/digikey/search_parts.py3
2 files changed, 5 insertions, 5 deletions
diff --git a/src/ee/digikey/__init__.py b/src/ee/digikey/__init__.py
index 3eb723e..15eb5e6 100644
--- a/src/ee/digikey/__init__.py
+++ b/src/ee/digikey/__init__.py
@@ -283,14 +283,13 @@ class DigikeyClient(object):
self.cache = ee._utils.maybe_cache(cache_dir)
self._driver: Optional[webdriver.Chrome] = None
- def search(self, query: str, page_size=10) -> str:
- return self.product_search(query, page_size)
+ def search(self, query: str) -> str:
+ return self.product_search(query)
def _find_first_visible(self, xpath):
return next((e for e in self.driver.find_elements_by_xpath(xpath) if e.is_displayed()), None)
- def product_search(self, query: str, page_size=10) -> str:
- params = {'lang': 'en', 'site': 'us', 'keywords': query, 'pageSize': str(page_size)}
+ def product_search(self, query: str) -> str:
cache_key = urllib.parse.quote(query)
cached = self.cache.lookup(cache_key)
diff --git a/src/ee/digikey/search_parts.py b/src/ee/digikey/search_parts.py
index e79959a..a1236bb 100644
--- a/src/ee/digikey/search_parts.py
+++ b/src/ee/digikey/search_parts.py
@@ -94,11 +94,12 @@ class QueryEngine(object):
out_part = resolved(self.store.url, response.products[0])
result = "found"
elif response.response_type == SearchResponseTypes.MANY:
+ # TODO: order by spn/mpn so the output is consistent between runs.
print("Got many responses:\n", file=self.log)
from ee._utils import gen_rst_table
- data = [[p.part_number, p.mpn] for p in response.products]
+ data = [[p.part_number, p.mpn] for p in sorted(response.products, key=lambda x: x.part_number)]
print(gen_rst_table(["DK", "MPN"], data), file=self.log)
# find those with an exact match. Digikey uses a "contains" search so a query for "FOO" will return "FOO",