mirror of
https://github.com/AllSpiceIO/cofactr-cogs.git
synced 2025-04-18 07:48:55 +00:00
Add check to require manufacturer column when search strategy would use it
This commit is contained in:
parent
8b8abb2a9c
commit
5503458e3e
@ -57,7 +57,7 @@ def fetch_price_for_part(
|
||||
)
|
||||
|
||||
query = part_number
|
||||
if search_strategy != "mpn_exact" and manufacturer:
|
||||
if query_needs_manufacturer(search_strategy) and manufacturer:
|
||||
query += f" {manufacturer}"
|
||||
|
||||
search_response = requests.get(
|
||||
@ -97,6 +97,10 @@ def fetch_price_for_part(
|
||||
return prices
|
||||
|
||||
|
||||
def query_needs_manufacturer(search_strategy: str) -> bool:
|
||||
return search_strategy != "mpn_exact"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = ArgumentParser()
|
||||
|
||||
@ -159,6 +163,10 @@ if __name__ == "__main__":
|
||||
prices_for_parts = {}
|
||||
|
||||
use_mfr = bool(manufacturer_column)
|
||||
if not use_mfr and query_needs_manufacturer(args.search_strategy):
|
||||
raise ValueError(
|
||||
"Search strategy requires manufacturer, but no BOM manufacturer column was provided"
|
||||
)
|
||||
|
||||
for part in parts:
|
||||
part_number = part[part_number_column]
|
||||
|
Loading…
Reference in New Issue
Block a user