6
mirror of https://github.com/AllSpiceIO/cofactr-cogs.git synced 2025-04-14 07:19:13 +00:00

Change to continue to output rows without prices

This commit is contained in:
Jonathan Tran 2024-05-13 18:22:19 -04:00
parent d453ad1cc4
commit cf045029e0
No known key found for this signature in database

View File

@ -181,9 +181,14 @@ if __name__ == "__main__":
for part in parts:
part_quantity = int(part[quantity_column])
first_part_number = None
prices_found = False
for part_number_column in part_number_columns:
part_number = part[part_number_column]
if first_part_number is None:
first_part_number = part_number
prices = prices_for_parts.get(part_number)
if prices is None:
# Prices not found. Try the next part number.
@ -205,12 +210,21 @@ if __name__ == "__main__":
current_row.append(None)
current_row.append(None)
# We found prices for this part number. We can stop trying other part numbers.
prices_found = True
rows.append(current_row)
# We created a row for this part number. We can stop trying other
# part numbers.
break
if not prices_found:
# No prices found for any part number. Add a row with the first part number and no
# prices.
assert first_part_number is not None
current_row = [first_part_number, part_quantity]
for quantity in quantities:
current_row.append(None)
current_row.append(None)
rows.append(current_row)
with ExitStack() as stack:
if args.output_file:
file = stack.enter_context(open(args.output_file, "w"))