hildogjr / KiCost

Build cost spreadsheet for a KiCad project.
MIT License
493 stars 97 forks source link

Nexar part fetch Index Error #540

Closed craigarno closed 1 year ago

craigarno commented 1 year ago

Normal run, seems a list index is exceeding whatever value it is set in the Nexar API

Progress: 100%|███████████████████████████████████████████████████| 31/31 [00:00<00:00, 55.76part/s]
- Nexar [api] (https://nexar.com/api)
Traceback (most recent call last):
  File "C:\Program Files\KiCad\6.0\bin\Lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\KiCad\6.0\bin\Lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\Scripts\kicost.exe\__main__.py", line 7, in <module>
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\__main__.py", line 471, in main
    main_real()
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\__main__.py", line 461, in main_real
    kicost(in_file=args.input, eda_name=args.eda,
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\kicost.py", line 251, in kicost
    query_part_info(parts, dist_list, currency)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\kicost.py", line 78, in query_part_info
    get_dist_parts_info(parts, dist_list, currency)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\distributors\__init__.py", line 50, in get_dist_parts_info
    distributor_class.get_dist_parts_info(parts, dist_list, currency)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\distributors\distributor.py", line 146, in get_dist_parts_info
    solved = api.query_part_info(parts, list(remaining), currency)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\distributors\api_nexar.py", line 635, in query_part_info
    api_nexar.fill_part_info(queries, distributors, currency, solved_dist)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\distributors\api_nexar.py", line 446, in fill_part_info
    result, no_offers = api_nexar.select_best_part(result, part, native_dists)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\distributors\api_nexar.py", line 392, in select_best_part
    best_match = difflib.get_close_matches(manf, manufacturers.keys())[0]
IndexError: list index out of range

Issue / Problem report

  1. Add the KiCost version. Type kicost --version at terminal.

    kicost --version KiCost v1.1.13

  2. Add a terminal error report / txt, use --debug option on KiCost call; kicost -w -i %YOUR_FILE% --debug 8

  3. Write the command used to call KiCost (or the graphical interface configuration); kicost -w -i "usbc-cypd3177-24lqxq.xml" --eda kicad

  4. One BoM to reproduce the error (with the EDA version).

DEBUG:Looking in cache C:\Users\craig\.cache\kicost\Nexar\mpn_Cypress_Semiconductor_CYPD3177-24LQXQ.dat (kicost.distributors - log.py:115)
DEBUG:Found in cache {'hits': 1, 'reference': 'q29', 'parts': [{'id': '102743253', 'slug': '/cypd3177-24lqxq-cypress+semiconductor-102743253', 'mpn': 'CYPD3177-24LQXQ', 'manufacturer': {'name': 'Cypress Semiconductor', 'id': '453'}, 'shortDescription': 'USB Type-C DFP Port Controller USB 1.1 3.3V/5V 24-Pin QFN EP', 'specs': [{'attribute': {'shortname': 'ambienttemperaturerangehigh', 'name': 'Ambient Temperature Range High', 'id': '903'}, 'displayValue': '105 °C'}, {'attribute': {'shortname': 'height', 'name': 'Height', 'id': '468'}, 'displayValue': '600 µm'}, {'attribute': {'shortname': 'interface', 'name': 'Interface', 'id': '731'}, 'displayValue': 'I2C, USB'}, {'attribute': {'shortname': 'maxjunctiontemperature', 'name': 'Max Junction Temperature (Tj)', 'id': '905'}, 'displayValue': '120 °C'}, {'attribute': {'shortname': 'maxoperatingtemperature', 'name': 'Max Operating Temperature', 'id': '849'}, 'displayValue': '120 °C'}, {'attribute': {'shortname': 'maxsupplyvoltage', 'name': 'Max Supply Voltage', 'id': '588'}, 'displayValue': '24.5 V'}, {'attribute': {'shortname': 'minoperatingtemperature', 'name': 'Min Operating Temperature', 'id': '456'}, 'displayValue': '-40 °C'}, {'attribute': {'shortname': 'minsupplyvoltage', 'name': 'Min Supply Voltage', 'id': '339'}, 'displayValue': '1.8 V'}, {'attribute': {'shortname': 'numberofports', 'name': 'Number of Ports', 'id': '733'}, 'displayValue': '1'}, {'attribute': {'shortname': 'rohs', 'name': 'RoHS', 'id': '610'}, 'displayValue': 'Compliant'}, {'attribute': {'shortname': 'scheduleB', 'name': 'Schedule B', 'id': '973'}, 'displayValue': '8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000, 8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000, 8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000, 8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|85'}, {'attribute': {'shortname': 'usbstandard', 'name': 'USB Standard', 'id': '673'}, 'displayValue': 'USB 3.0'}], 'octopartUrl': 'https://octopart.com/cypd3177-24lqxq-cypress+semiconductor-102743253', 'bestDatasheet': None, 'sellers': [{'company': {'name': 'Win Source Electronics', 'id': '8706'}, 'offers': [{'sku': '1253176-CYPD3177-24LQXQ', 'id': '846101748', 'inventoryLevel': 4910, 'moq': 3, 'orderMultiple': None, 'packaging': None, 'prices': [{'quantity': 3, 'price': 23.146, 'currency': 'USD'}, {'quantity': 6, 'price': 19.194, 'currency': 'USD'}, {'quantity': 9, 'price': 18.629, 'currency': 'USD'}, {'quantity': 12, 'price': 18.065, 'currency': 'USD'}, {'quantity': 15, 'price': 17.5, 'currency': 'USD'}, {'quantity': 19, 'price': 15.807, 'currency': 'USD'}], 'onOrderQuantity': None, 'clickUrl': 'https://octopart.com/opatz8j6/a1?t=_eMPI0GobMt6EOlYYhOjVnN0tKJzlxOuIu7qS_8abgYYyF7WdyUjZy-Q49u08cP9bvG24m0KoKARGTYJb2fTKxzmImAyIIx9F-puM8cqY0x275Pn3Uk7GP3hb-8uilv8_3aCn4WBSKBUoA6-NcuB-VYY_kYean4iRvhHZ-3I3Vzkw4zzdfIsD2sWRbiAXxl-9MY81FgOHjc_D6DlIxwDrTKQX9lyjVUSj3cL-P2D85ipgkXM_KfZ-TnOv8TsjYN5Xj0KhGkJnjw'}]}, {'company': {'name': 'LCSC', 'id': '11779'}, 'offers': [{'sku': 'C2959321', 'id': '831523945', 'inventoryLevel': 4750, 'moq': 1, 'orderMultiple': 1, 'packaging': 'Tray', 'prices': [{'quantity': 1, 'price': 2.5341, 'currency': 'AUD'}, {'quantity': 1, 'price': 2.4485, 'currency': 'CAD'}, {'quantity': 1, 'price': 12.8077, 'currency': 'CNY'}, {'quantity': 1, 'price': 12.1603, 'currency': 'DKK'}, {'quantity': 1, 'price': 1.6355, 'currency': 'EUR'}, {'quantity': 1, 'price': 1.4216, 'currency': 'GBP'}, {'quantity': 1, 'price': 15.3242, 'currency': 'HKD'}, {'quantity': 1, 'price': 213.7979, 'currency': 'JPY'}, {'quantity': 1, 'price': 8.0931, 'currency': 'MYR'}, {'quantity': 1, 'price': 148.0454, 'currency': 'RUB'}, {'quantity': 1, 'price': 16.5591, 'currency': 'SEK'}, {'quantity': 1, 'price': 2.6191, 'currency': 'SGD'}, {'quantity': 1, 'price': 1.9744, 'currency': 'USD'}, {'quantity': 10, 'price': 2.2706, 'currency': 'AUD'}, {'quantity': 10, 'price': 2.1939, 'currency': 'CAD'}, {'quantity': 10, 'price': 11.476, 'currency': 'CNY'}, {'quantity': 10, 'price': 10.8959, 'currency': 'DKK'}, {'quantity': 10, 'price': 1.4654, 'currency': 'EUR'}, {'quantity': 10, 'price': 1.2738, 'currency': 'GBP'}, {'quantity': 10, 'price': 13.7308, 'currency': 'HKD'}, {'quantity': 10, 'price': 191.567, 'currency': 'JPY'}, {'quantity': 10, 'price': 7.2515, 'currency': 'MYR'}, {'quantity': 10, 'price': 132.6515, 'currency': 'RUB'}, {'quantity': 10, 'price': 14.8373, 'currency': 'SEK'}, {'quantity': 10, 'price': 2.3468, 'currency': 'SGD'}, {'quantity': 10, 'price': 1.7691, 'currency': 'USD'}, {'quantity': 30, 'price': 2.1053, 'currency': 'AUD'}, {'quantity': 30, 'price': 2.0342, 'currency': 'CAD'}, {'quantity': 30, 'price': 10.6405, 'currency': 'CNY'}, {'quantity': 30, 'price': 10.1026, 'currency': 'DKK'}, {'quantity': 30, 'price': 1.3587, 'currency': 'EUR'}, {'quantity': 30, 'price': 1.181, 'currency': 'GBP'}, {'quantity': 30, 'price': 12.7311, 'currency': 'HKD'}, {'quantity': 30, 'price': 177.6199, 'currency': 'JPY'}, {'quantity': 30, 'price': 6.7236, 'currency': 'MYR'}, {'quantity': 30, 'price': 122.9938, 'currency': 'RUB'}, {'quantity': 30, 'price': 13.757, 'currency': 'SEK'}, {'quantity': 30, 'price': 2.1759, 'currency': 'SGD'}, {'quantity': 30, 'price': 1.6403, 'currency': 'USD'}, {'quantity': 100, 'price': 1.9358, 'currency': 'AUD'}, {'quantity': 100, 'price': 1.8704, 'currency': 'CAD'}, {'quantity': 100, 'price': 9.7835, 'currency': 'CNY'}, {'quantity': 100, 'price': 9.289, 'currency': 'DKK'}, {'quantity': 100, 'price': 1.2493, 'currency': 'EUR'}, {'quantity': 100, 'price': 1.0859, 'currency': 'GBP'}, {'quantity': 100, 'price': 11.7058, 'currency': 'HKD'}, {'quantity': 100, 'price': 163.3154, 'currency': 'JPY'}, {'quantity': 100, 'price': 6.1821, 'currency': 'MYR'}, {'quantity': 100, 'price': 113.0886, 'currency': 'RUB'}, {'quantity': 100, 'price': 12.6491, 'currency': 'SEK'}, {'quantity': 100, 'price': 2.0007, 'currency': 'SGD'}, {'quantity': 100, 'price': 1.5082, 'currency': 'USD'}, {'quantity': 490, 'price': 1.8603, 'currency': 'AUD'}, {'quantity': 490, 'price': 1.7974, 'currency': 'CAD'}, {'quantity': 490, 'price': 9.4021, 'currency': 'CNY'}, {'quantity': 490, 'price': 8.9268, 'currency': 'DKK'}, {'quantity': 490, 'price': 1.2006, 'currency': 'EUR'}, {'quantity': 490, 'price': 1.0436, 'currency': 'GBP'}, {'quantity': 490, 'price': 11.2494, 'currency': 'HKD'}, {'quantity': 490, 'price': 156.9483, 'currency': 'JPY'}, {'quantity': 490, 'price': 5.9411, 'currency': 'MYR'}, {'quantity': 490, 'price': 108.6796, 'currency': 'RUB'}, {'quantity': 490, 'price': 12.156, 'currency': 'SEK'}, {'quantity': 490, 'price': 1.9227, 'currency': 'SGD'}, {'quantity': 490, 'price': 1.4494, 'currency': 'USD'}, {'quantity': 980, 'price': 1.8276, 'currency': 'AUD'}, {'quantity': 980, 'price': 1.7658, 'currency': 'CAD'}, {'quantity': 980, 'price': 9.2367, 'currency': 'CNY'}, {'quantity': 980, 'price': 8.7698, 'currency': 'DKK'}, {'quantity': 980, 'price': 1.1795, 'currency': 'EUR'}, {'quantity': 980, 'price': 1.0252, 'currency': 'GBP'}, {'quantity': 980, 'price': 11.0515, 'currency': 'HKD'}, {'quantity': 980, 'price': 154.187, 'currency': 'JPY'}, {'quantity': 980, 'price': 5.8366, 'currency': 'MYR'}, {'quantity': 980, 'price': 106.7676, 'currency': 'RUB'}, {'quantity': 980, 'price': 11.9421, 'currency': 'SEK'}, {'quantity': 980, 'price': 1.8889, 'currency': 'SGD'}, {'quantity': 980, 'price': 1.4239, 'currency': 'USD'}], 'onOrderQuantity': None, 'clickUrl': 'https://octopart.com/opatz8j6/a1?t=nIpcERdGbsJuN44P79C8e4rf0uI1nmlvtAnlxxdTl7JLNZxfubjSxifoOFDZpt3p8kHKGY35uSErrBRgawlNShUIUZFVVYqUIKYRNK6NQnvoUM0DzQSJAIKKyPgWffDiji0Joso7a8okiD_GxaDgwRv67XqoCJmdqokjpEebtP924msJesONZKLC7CiXFDTkWEUaKLiQtuKmesRvnQFP-ek3nMR0rQ-nDlSYPN7zxHzn2a3qu18iLSKl0PhO4CYdu_h3c3IvYfU'}]}, {'company': {'name': 'Sourcengine', 'id': '13036'}, 'offers': [{'sku': 'CYPD3177-24LQXQ-145229765822', 'id': '854290182', 'inventoryLevel': 10000, 'moq': None, 'orderMultiple': None, 'packaging': None, 'prices': [], 'onOrderQuantity': None, 'clickUrl': 'https://octopart.com/opatz8j6/a1?t=bKOw_JTgL522H-q2UaFxFLDPuJbHoeYltJfmwkej774X-5eDW2TdeExM5_v_3PeFknp1XZNZgLznSUOLAnlMXVqStgBvxKDBjjmVl-sO-I3BZyMkKvmgI97kBF-L3ctiTYS1bdRO7FH1Y6mK5TdRTzp8bMXqWS0-AiCFp3vGpuVmuhbhnmkhiaxiKUA4SanXPxzPhwZPvXIRCHBYmLZ0JuQ5GQPJP7MjiBfMlFm1pbnyH62CQveaMokbb0haQyj3pwcPmTIzfFk'}]}, {'company': {'name': 'Utmel Electronic', 'id': '12749'}, 'offers': [{'sku': '217-CYPD3177-24LQXQ', 'id': '837129337', 'inventoryLevel': 3854, 'moq': None, 'orderMultiple': None, 'packaging': None, 'prices': [], 'onOrderQuantity': None, 'clickUrl': 'https://octopart.com/opatz8j6/a1?t=hiMwdxPtmJeSgYskS1SYgbEmP_coFqYtiRiKIIMNdbFTv8QdNoz_25uPENOrJNypMCAxpC5U6xufLY3c8HYZFV10zkuctyFZZAB54xOQ8983bxSmFYw41I_enWXOJ4dLoJuRKCUqJLupBztCK4N10SZv1JIEF3H6hsEm7D7WiI-CSgtiCt32ZfbpH-vF9BdouE6QmThcP8jg6zV4MgOaQ-UZHmlknEjGmRK9zPcUUE-o4T_PyxXYwV0WYP5UILdOSYbL6g1kPMM'}]}, {'company': {'name': 'Corohmni', 'id': '12977'}, 'offers': [{'sku': 'CYPD3177-24LQXQ', 'id': '866113333', 'inventoryLevel': 500, 'moq': None, 'orderMultiple': None, 'packaging': None, 'prices': [], 'onOrderQuantity': None, 'clickUrl': 'https://octopart.com/opatz8j6/a1?t=vEdSdgziya6xPVtgICAgjksCct--sinmeh-HDqL04uwO0PiEY4IrTNLBerQc_UfDHIw6OFlWxIsEqxoViephMzMJP8wML06BXdrCsCu29XjomPrm1OYk33BeyfK_msR8On6iSJVObiwzTovwvFRiANMIlx1b9ugbH_vfU9yzHdjQfP2ZQ5QbQMHgDoXDoY0ESO0-kwioqkBtdG0m3JW16qimtlTYThBG6YsS8LIxTC4VQubLqpqZOI9ZX_fHKcq1XDUgQjotABI'}]}, {'company': {'name': 'Heisener Electronics', 'id': '13693'}, 'offers': [{'sku': 'CYPD3177-24LQXQ', 'id': '815306972', 'inventoryLevel': 7163, 'moq': None, 'orderMultiple': None, 'packaging': None, 'prices': [], 'onOrderQuantity': None, 'clickUrl': 'https://octopart.com/opatz8j6/a1?t=rhda6zKv1fB_H6zm0rOA3gVZJIPaazaaHcYuvXmFmqxuWtBUfB_pPFiRGwBYXGWd4XziPZfsmn82ZiD4mS8NwzKMbBFCvA0asGlCeDj-LB_MemCJhS9NcrQMP2UpO3791iJcPxOWMMduSFPPTgqjYKi2-CMotR3z00RQ-enyogdMhM10yGN3EWRTnJ4IgicaQEvDeJ_CsubcV9dDQ3X0Q8mz0ee1I3un48Qp1GoM_-bom2RyZfhuQY7LcMOK7TWEa2PqdKe_zBk'}]}, {'company': {'name': 'Extreme Components', 'id': '12899'}, 'offers': [{'sku': 'CYPD3177-24LQXQ', 'id': '659968106', 'inventoryLevel': 980, 'moq': None, 'orderMultiple': None, 'packaging': None, 'prices': [], 'onOrderQuantity': None, 'clickUrl': 'https://octopart.com/opatz8j6/a1?t=XQoub-voEy2O6k6WcIhigRG_e9GM00Vd3rVoR3QP55dMyM_xaAhiQAZFZF4xebQSDJDzUjRPlX1uZht-3OZ0Lq5KwIYUQ16cf8_N5Zt52rwr-ydkZOybX6Ztu2sim8DD3-gX6FJf_UUfVIIBrPJpjzhMr_dYAugaZNRhPhhZGUN3AucGgc62ua3p552qna1poBAxCpAYQgmLBc2pamYhSSLOy3ezP85gj_gL8qml2cHkERJH6kWbAN_7gPXElLRqBP72EOl_Xoc'}]}, {'company': {'name': 'GreenTree Electronics', 'id': '8169'}, 'offers': [{'sku': 'CYPD3177-24LQXQ', 'id': '839822866', 'inventoryLevel': 10000, 'moq': None, 'orderMultiple': None, 'packaging': None, 'prices': [], 'onOrderQuantity': None, 'clickUrl': 'https://octopart.com/opatz8j6/a1?t=HkCXo43_n2qSk96gbdoot0RRbygHXWiUAMuaMiRLug1ZezGxWQANv3LPPY-K2C9WXQ0OgGAVHKQ_XOejxwBrEXECoU3tBcmu7bp7szwAbQbvFzIDxt7gw8rwKpX2UJiYzmgFpQoLYx5ffq_UmONTWrz67rWre2WCqHDQVvgzjGGE4WFsZV0fV7k9R9TbQtf2S2jNaTu4IUjbafyzUL74dZG3rwZbad-424bMQoa78xfnbf-i4QR_qNI5aYTiY8wA5fBukB6i6w'}]}, {'company': {'name': 'Abacus Technologies', 'id': '10079'}, 'offers': [{'sku': 'CYPD3177-24LQXQ', 'id': '594908908', 'inventoryLevel': 385, 'moq': None, 'orderMultiple': None, 'packaging': None, 'prices': [], 'onOrderQuantity': None, 'clickUrl': 'https://octopart.com/opatz8j6/a1?t=RQ04pOip0tiV1ff70OaNmQuK9Q4U_K04gLEfkILKwbc8g4aY_5rEyYaOSNy6QfxCNGNnwK5-tw0VzeIzdyCJYZbZRZiJJWqADYW9nohHtB-Wz62-W1Wcp4P_xLlDR3yZH5xzysoJLUcBZ5KJSEvAJLrJo21T9CY_Hsr1Ma1YQDPcVeCb76ur4chDVLt7EuLRWRf6GefZzEd30q189hc2nv-FCnoN4b-YKx6sULrxXDj7sC8z7TYoNnX43s8elRm527rPQguULQ'}]}]}]} (kicost.distributors - log.py:115)
DEBUG:Data from cache: {'hits': 1,
 'parts': [{'bestDatasheet': None,
            'id': '102743253',
            'manufacturer': {'id': '453', 'name': 'Cypress Semiconductor'},
            'mpn': 'CYPD3177-24LQXQ',
            'octopartUrl': 'https://octopart.com/cypd3177-24lqxq-cypress+semiconductor-102743253',
            'sellers': [{'company': {'id': '8706',
                                     'name': 'Win Source Electronics'},
                         'offers': [{'clickUrl': 'https://octopart.com/opatz8j6/a1?t=_eMPI0GobMt6EOlYYhOjVnN0tKJzlxOuIu7qS_8abgYYyF7WdyUjZy-Q49u08cP9bvG24m0KoKARGTYJb2fTKxzmImAyIIx9F-puM8cqY0x275Pn3Uk7GP3hb-8uilv8_3aCn4WBSKBUoA6-NcuB-VYY_kYean4iRvhHZ-3I3Vzkw4zzdfIsD2sWRbiAXxl-9MY81FgOHjc_D6DlIxwDrTKQX9lyjVUSj3cL-P2D85ipgkXM_KfZ-TnOv8TsjYN5Xj0KhGkJnjw',
                                     'id': '846101748',
                                     'inventoryLevel': 4910,
                                     'moq': 3,
                                     'onOrderQuantity': None,
                                     'orderMultiple': None,
                                     'packaging': None,
                                     'prices': [{'currency': 'USD',
                                                 'price': 23.146,
                                                 'quantity': 3},
                                                {'currency': 'USD',
                                                 'price': 19.194,
                                                 'quantity': 6},
                                                {'currency': 'USD',
                                                 'price': 18.629,
                                                 'quantity': 9},
                                                {'currency': 'USD',
                                                 'price': 18.065,
                                                 'quantity': 12},
                                                {'currency': 'USD',
                                                 'price': 17.5,
                                                 'quantity': 15},
                                                {'currency': 'USD',
                                                 'price': 15.807,
                                                 'quantity': 19}],
                                     'sku': '1253176-CYPD3177-24LQXQ'}]},
                        {'company': {'id': '11779', 'name': 'LCSC'},
                         'offers': [{'clickUrl': 'https://octopart.com/opatz8j6/a1?t=nIpcERdGbsJuN44P79C8e4rf0uI1nmlvtAnlxxdTl7JLNZxfubjSxifoOFDZpt3p8kHKGY35uSErrBRgawlNShUIUZFVVYqUIKYRNK6NQnvoUM0DzQSJAIKKyPgWffDiji0Joso7a8okiD_GxaDgwRv67XqoCJmdqokjpEebtP924msJesONZKLC7CiXFDTkWEUaKLiQtuKmesRvnQFP-ek3nMR0rQ-nDlSYPN7zxHzn2a3qu18iLSKl0PhO4CYdu_h3c3IvYfU',
                                     'id': '831523945',
                                     'inventoryLevel': 4750,
                                     'moq': 1,
                                     'onOrderQuantity': None,
                                     'orderMultiple': 1,
                                     'packaging': 'Tray',
                                     'prices': [{'currency': 'AUD',
                                                 'price': 2.5341,
                                                 'quantity': 1},
                                                {'currency': 'CAD',
                                                 'price': 2.4485,
                                                 'quantity': 1},
                                                {'currency': 'CNY',
                                                 'price': 12.8077,
                                                 'quantity': 1},
                                                {'currency': 'DKK',
                                                 'price': 12.1603,
                                                 'quantity': 1},
                                                {'currency': 'EUR',
                                                 'price': 1.6355,
                                                 'quantity': 1},
                                                {'currency': 'GBP',
                                                 'price': 1.4216,
                                                 'quantity': 1},
                                                {'currency': 'HKD',
                                                 'price': 15.3242,
                                                 'quantity': 1},
                                                {'currency': 'JPY',
                                                 'price': 213.7979,
                                                 'quantity': 1},
                                                {'currency': 'MYR',
                                                 'price': 8.0931,
                                                 'quantity': 1},
                                                {'currency': 'RUB',
                                                 'price': 148.0454,
                                                 'quantity': 1},
                                                {'currency': 'SEK',
                                                 'price': 16.5591,
                                                 'quantity': 1},
                                                {'currency': 'SGD',
                                                 'price': 2.6191,
                                                 'quantity': 1},
                                                {'currency': 'USD',
                                                 'price': 1.9744,
                                                 'quantity': 1},
                                                {'currency': 'AUD',
                                                 'price': 2.2706,
                                                 'quantity': 10},
                                                {'currency': 'CAD',
                                                 'price': 2.1939,
                                                 'quantity': 10},
                                                {'currency': 'CNY',
                                                 'price': 11.476,
                                                 'quantity': 10},
                                                {'currency': 'DKK',
                                                 'price': 10.8959,
                                                 'quantity': 10},
                                                {'currency': 'EUR',
                                                 'price': 1.4654,
                                                 'quantity': 10},
                                                {'currency': 'GBP',
                                                 'price': 1.2738,
                                                 'quantity': 10},
                                                {'currency': 'HKD',
                                                 'price': 13.7308,
                                                 'quantity': 10},
                                                {'currency': 'JPY',
                                                 'price': 191.567,
                                                 'quantity': 10},
                                                {'currency': 'MYR',
                                                 'price': 7.2515,
                                                 'quantity': 10},
                                                {'currency': 'RUB',
                                                 'price': 132.6515,
                                                 'quantity': 10},
                                                {'currency': 'SEK',
                                                 'price': 14.8373,
                                                 'quantity': 10},
                                                {'currency': 'SGD',
                                                 'price': 2.3468,
                                                 'quantity': 10},
                                                {'currency': 'USD',
                                                 'price': 1.7691,
                                                 'quantity': 10},
                                                {'currency': 'AUD',
                                                 'price': 2.1053,
                                                 'quantity': 30},
                                                {'currency': 'CAD',
                                                 'price': 2.0342,
                                                 'quantity': 30},
                                                {'currency': 'CNY',
                                                 'price': 10.6405,
                                                 'quantity': 30},
                                                {'currency': 'DKK',
                                                 'price': 10.1026,
                                                 'quantity': 30},
                                                {'currency': 'EUR',
                                                 'price': 1.3587,
                                                 'quantity': 30},
                                                {'currency': 'GBP',
                                                 'price': 1.181,
                                                 'quantity': 30},
                                                {'currency': 'HKD',
                                                 'price': 12.7311,
                                                 'quantity': 30},
                                                {'currency': 'JPY',
                                                 'price': 177.6199,
                                                 'quantity': 30},
                                                {'currency': 'MYR',
                                                 'price': 6.7236,
                                                 'quantity': 30},
                                                {'currency': 'RUB',
                                                 'price': 122.9938,
                                                 'quantity': 30},
                                                {'currency': 'SEK',
                                                 'price': 13.757,
                                                 'quantity': 30},
                                                {'currency': 'SGD',
                                                 'price': 2.1759,
                                                 'quantity': 30},
                                                {'currency': 'USD',
                                                 'price': 1.6403,
                                                 'quantity': 30},
                                                {'currency': 'AUD',
                                                 'price': 1.9358,
                                                 'quantity': 100},
                                                {'currency': 'CAD',
                                                 'price': 1.8704,
                                                 'quantity': 100},
                                                {'currency': 'CNY',
                                                 'price': 9.7835,
                                                 'quantity': 100},
                                                {'currency': 'DKK',
                                                 'price': 9.289,
                                                 'quantity': 100},
                                                {'currency': 'EUR',
                                                 'price': 1.2493,
                                                 'quantity': 100},
                                                {'currency': 'GBP',
                                                 'price': 1.0859,
                                                 'quantity': 100},
                                                {'currency': 'HKD',
                                                 'price': 11.7058,
                                                 'quantity': 100},
                                                {'currency': 'JPY',
                                                 'price': 163.3154,
                                                 'quantity': 100},
                                                {'currency': 'MYR',
                                                 'price': 6.1821,
                                                 'quantity': 100},
                                                {'currency': 'RUB',
                                                 'price': 113.0886,
                                                 'quantity': 100},
                                                {'currency': 'SEK',
                                                 'price': 12.6491,
                                                 'quantity': 100},
                                                {'currency': 'SGD',
                                                 'price': 2.0007,
                                                 'quantity': 100},
                                                {'currency': 'USD',
                                                 'price': 1.5082,
                                                 'quantity': 100},
                                                {'currency': 'AUD',
                                                 'price': 1.8603,
                                                 'quantity': 490},
                                                {'currency': 'CAD',
                                                 'price': 1.7974,
                                                 'quantity': 490},
                                                {'currency': 'CNY',
                                                 'price': 9.4021,
                                                 'quantity': 490},
                                                {'currency': 'DKK',
                                                 'price': 8.9268,
                                                 'quantity': 490},
                                                {'currency': 'EUR',
                                                 'price': 1.2006,
                                                 'quantity': 490},
                                                {'currency': 'GBP',
                                                 'price': 1.0436,
                                                 'quantity': 490},
                                                {'currency': 'HKD',
                                                 'price': 11.2494,
                                                 'quantity': 490},
                                                {'currency': 'JPY',
                                                 'price': 156.9483,
                                                 'quantity': 490},
                                                {'currency': 'MYR',
                                                 'price': 5.9411,
                                                 'quantity': 490},
                                                {'currency': 'RUB',
                                                 'price': 108.6796,
                                                 'quantity': 490},
                                                {'currency': 'SEK',
                                                 'price': 12.156,
                                                 'quantity': 490},
                                                {'currency': 'SGD',
                                                 'price': 1.9227,
                                                 'quantity': 490},
                                                {'currency': 'USD',
                                                 'price': 1.4494,
                                                 'quantity': 490},
                                                {'currency': 'AUD',
                                                 'price': 1.8276,
                                                 'quantity': 980},
                                                {'currency': 'CAD',
                                                 'price': 1.7658,
                                                 'quantity': 980},
                                                {'currency': 'CNY',
                                                 'price': 9.2367,
                                                 'quantity': 980},
                                                {'currency': 'DKK',
                                                 'price': 8.7698,
                                                 'quantity': 980},
                                                {'currency': 'EUR',
                                                 'price': 1.1795,
                                                 'quantity': 980},
                                                {'currency': 'GBP',
                                                 'price': 1.0252,
                                                 'quantity': 980},
                                                {'currency': 'HKD',
                                                 'price': 11.0515,
                                                 'quantity': 980},
                                                {'currency': 'JPY',
                                                 'price': 154.187,
                                                 'quantity': 980},
                                                {'currency': 'MYR',
                                                 'price': 5.8366,
                                                 'quantity': 980},
                                                {'currency': 'RUB',
                                                 'price': 106.7676,
                                                 'quantity': 980},
                                                {'currency': 'SEK',
                                                 'price': 11.9421,
                                                 'quantity': 980},
                                                {'currency': 'SGD',
                                                 'price': 1.8889,
                                                 'quantity': 980},
                                                {'currency': 'USD',
                                                 'price': 1.4239,
                                                 'quantity': 980}],
                                     'sku': 'C2959321'}]},
                        {'company': {'id': '13036', 'name': 'Sourcengine'},
                         'offers': [{'clickUrl': 'https://octopart.com/opatz8j6/a1?t=bKOw_JTgL522H-q2UaFxFLDPuJbHoeYltJfmwkej774X-5eDW2TdeExM5_v_3PeFknp1XZNZgLznSUOLAnlMXVqStgBvxKDBjjmVl-sO-I3BZyMkKvmgI97kBF-L3ctiTYS1bdRO7FH1Y6mK5TdRTzp8bMXqWS0-AiCFp3vGpuVmuhbhnmkhiaxiKUA4SanXPxzPhwZPvXIRCHBYmLZ0JuQ5GQPJP7MjiBfMlFm1pbnyH62CQveaMokbb0haQyj3pwcPmTIzfFk',
                                     'id': '854290182',
                                     'inventoryLevel': 10000,
                                     'moq': None,
                                     'onOrderQuantity': None,
                                     'orderMultiple': None,
                                     'packaging': None,
                                     'prices': [],
                                     'sku': 'CYPD3177-24LQXQ-145229765822'}]},
                        {'company': {'id': '12749', 'name': 'Utmel Electronic'},
                         'offers': [{'clickUrl': 'https://octopart.com/opatz8j6/a1?t=hiMwdxPtmJeSgYskS1SYgbEmP_coFqYtiRiKIIMNdbFTv8QdNoz_25uPENOrJNypMCAxpC5U6xufLY3c8HYZFV10zkuctyFZZAB54xOQ8983bxSmFYw41I_enWXOJ4dLoJuRKCUqJLupBztCK4N10SZv1JIEF3H6hsEm7D7WiI-CSgtiCt32ZfbpH-vF9BdouE6QmThcP8jg6zV4MgOaQ-UZHmlknEjGmRK9zPcUUE-o4T_PyxXYwV0WYP5UILdOSYbL6g1kPMM',
                                     'id': '837129337',
                                     'inventoryLevel': 3854,
                                     'moq': None,
                                     'onOrderQuantity': None,
                                     'orderMultiple': None,
                                     'packaging': None,
                                     'prices': [],
                                     'sku': '217-CYPD3177-24LQXQ'}]},
                        {'company': {'id': '12977', 'name': 'Corohmni'},
                         'offers': [{'clickUrl': 'https://octopart.com/opatz8j6/a1?t=vEdSdgziya6xPVtgICAgjksCct--sinmeh-HDqL04uwO0PiEY4IrTNLBerQc_UfDHIw6OFlWxIsEqxoViephMzMJP8wML06BXdrCsCu29XjomPrm1OYk33BeyfK_msR8On6iSJVObiwzTovwvFRiANMIlx1b9ugbH_vfU9yzHdjQfP2ZQ5QbQMHgDoXDoY0ESO0-kwioqkBtdG0m3JW16qimtlTYThBG6YsS8LIxTC4VQubLqpqZOI9ZX_fHKcq1XDUgQjotABI',
                                     'id': '866113333',
                                     'inventoryLevel': 500,
                                     'moq': None,
                                     'onOrderQuantity': None,
                                     'orderMultiple': None,
                                     'packaging': None,
                                     'prices': [],
                                     'sku': 'CYPD3177-24LQXQ'}]},
                        {'company': {'id': '13693',
                                     'name': 'Heisener Electronics'},
                         'offers': [{'clickUrl': 'https://octopart.com/opatz8j6/a1?t=rhda6zKv1fB_H6zm0rOA3gVZJIPaazaaHcYuvXmFmqxuWtBUfB_pPFiRGwBYXGWd4XziPZfsmn82ZiD4mS8NwzKMbBFCvA0asGlCeDj-LB_MemCJhS9NcrQMP2UpO3791iJcPxOWMMduSFPPTgqjYKi2-CMotR3z00RQ-enyogdMhM10yGN3EWRTnJ4IgicaQEvDeJ_CsubcV9dDQ3X0Q8mz0ee1I3un48Qp1GoM_-bom2RyZfhuQY7LcMOK7TWEa2PqdKe_zBk',
                                     'id': '815306972',
                                     'inventoryLevel': 7163,
                                     'moq': None,
                                     'onOrderQuantity': None,
                                     'orderMultiple': None,
                                     'packaging': None,
                                     'prices': [],
                                     'sku': 'CYPD3177-24LQXQ'}]},
                        {'company': {'id': '12899',
                                     'name': 'Extreme Components'},
                         'offers': [{'clickUrl': 'https://octopart.com/opatz8j6/a1?t=XQoub-voEy2O6k6WcIhigRG_e9GM00Vd3rVoR3QP55dMyM_xaAhiQAZFZF4xebQSDJDzUjRPlX1uZht-3OZ0Lq5KwIYUQ16cf8_N5Zt52rwr-ydkZOybX6Ztu2sim8DD3-gX6FJf_UUfVIIBrPJpjzhMr_dYAugaZNRhPhhZGUN3AucGgc62ua3p552qna1poBAxCpAYQgmLBc2pamYhSSLOy3ezP85gj_gL8qml2cHkERJH6kWbAN_7gPXElLRqBP72EOl_Xoc',
                                     'id': '659968106',
                                     'inventoryLevel': 980,
                                     'moq': None,
                                     'onOrderQuantity': None,
                                     'orderMultiple': None,
                                     'packaging': None,
                                     'prices': [],
                                     'sku': 'CYPD3177-24LQXQ'}]},
                        {'company': {'id': '8169',
                                     'name': 'GreenTree Electronics'},
                         'offers': [{'clickUrl': 'https://octopart.com/opatz8j6/a1?t=HkCXo43_n2qSk96gbdoot0RRbygHXWiUAMuaMiRLug1ZezGxWQANv3LPPY-K2C9WXQ0OgGAVHKQ_XOejxwBrEXECoU3tBcmu7bp7szwAbQbvFzIDxt7gw8rwKpX2UJiYzmgFpQoLYx5ffq_UmONTWrz67rWre2WCqHDQVvgzjGGE4WFsZV0fV7k9R9TbQtf2S2jNaTu4IUjbafyzUL74dZG3rwZbad-424bMQoa78xfnbf-i4QR_qNI5aYTiY8wA5fBukB6i6w',
                                     'id': '839822866',
                                     'inventoryLevel': 10000,
                                     'moq': None,
                                     'onOrderQuantity': None,
                                     'orderMultiple': None,
                                     'packaging': None,
                                     'prices': [],
                                     'sku': 'CYPD3177-24LQXQ'}]},
                        {'company': {'id': '10079',
                                     'name': 'Abacus Technologies'},
                         'offers': [{'clickUrl': 'https://octopart.com/opatz8j6/a1?t=RQ04pOip0tiV1ff70OaNmQuK9Q4U_K04gLEfkILKwbc8g4aY_5rEyYaOSNy6QfxCNGNnwK5-tw0VzeIzdyCJYZbZRZiJJWqADYW9nohHtB-Wz62-W1Wcp4P_xLlDR3yZH5xzysoJLUcBZ5KJSEvAJLrJo21T9CY_Hsr1Ma1YQDPcVeCb76ur4chDVLt7EuLRWRf6GefZzEd30q189hc2nv-FCnoN4b-YKx6sULrxXDj7sC8z7TYoNnX43s8elRm527rPQguULQ',
                                     'id': '594908908',
                                     'inventoryLevel': 385,
                                     'moq': None,
                                     'onOrderQuantity': None,
                                     'orderMultiple': None,
                                     'packaging': None,
                                     'prices': [],
                                     'sku': 'CYPD3177-24LQXQ'}]}],
            'shortDescription': 'USB Type-C DFP Port Controller USB 1.1 '
                                '3.3V/5V 24-Pin QFN EP',
            'slug': '/cypd3177-24lqxq-cypress+semiconductor-102743253',
            'specs': [{'attribute': {'id': '903',
                                     'name': 'Ambient Temperature Range High',
                                     'shortname': 'ambienttemperaturerangehigh'},
                       'displayValue': '105 °C'},
                      {'attribute': {'id': '468',
                                     'name': 'Height',
                                     'shortname': 'height'},
                       'displayValue': '600 µm'},
                      {'attribute': {'id': '731',
                                     'name': 'Interface',
                                     'shortname': 'interface'},
                       'displayValue': 'I2C, USB'},
                      {'attribute': {'id': '905',
                                     'name': 'Max Junction Temperature (Tj)',
                                     'shortname': 'maxjunctiontemperature'},
                       'displayValue': '120 °C'},
                      {'attribute': {'id': '849',
                                     'name': 'Max Operating Temperature',
                                     'shortname': 'maxoperatingtemperature'},
                       'displayValue': '120 °C'},
                      {'attribute': {'id': '588',
                                     'name': 'Max Supply Voltage',
                                     'shortname': 'maxsupplyvoltage'},
                       'displayValue': '24.5 V'},
                      {'attribute': {'id': '456',
                                     'name': 'Min Operating Temperature',
                                     'shortname': 'minoperatingtemperature'},
                       'displayValue': '-40 °C'},
                      {'attribute': {'id': '339',
                                     'name': 'Min Supply Voltage',
                                     'shortname': 'minsupplyvoltage'},
                       'displayValue': '1.8 V'},
                      {'attribute': {'id': '733',
                                     'name': 'Number of Ports',
                                     'shortname': 'numberofports'},
                       'displayValue': '1'},
                      {'attribute': {'id': '610',
                                     'name': 'RoHS',
                                     'shortname': 'rohs'},
                       'displayValue': 'Compliant'},
                      {'attribute': {'id': '973',
                                     'name': 'Schedule B',
                                     'shortname': 'scheduleB'},
                       'displayValue': '8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000, '
                                       '8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000, '
                                       '8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000, '
                                       '8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|8542310000|85'},
                      {'attribute': {'id': '673',
                                     'name': 'USB Standard',
                                     'shortname': 'usbstandard'},
                       'displayValue': 'USB 3.0'}]}],
 'reference': 'q29'} (kicost.distributors - log.py:115)
DEBUG:Cached entries 31 (of 31) (kicost.distributors - log.py:115)
DEBUG:Hits: 1 (kicost.distributors - log.py:115)
DEBUG:Hits: 1 (kicost.distributors - log.py:115)
DEBUG:Hits: 1 (kicost.distributors - log.py:115)
DEBUG:Hits: 1 (kicost.distributors - log.py:115)
DEBUG:Hits: 1 (kicost.distributors - log.py:115)
DEBUG:Hits: 1 (kicost.distributors - log.py:115)
DEBUG:Hits: 2 (kicost.distributors - log.py:115)
DEBUG:Hits: 2 (kicost.distributors - log.py:115)
DEBUG:Hits: 1 (kicost.distributors - log.py:115)
DEBUG:Hits: 53 (kicost.distributors - log.py:115)
Traceback (most recent call last):
  File "C:\Program Files\KiCad\6.0\bin\Lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\KiCad\6.0\bin\Lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\Scripts\kicost.exe\__main__.py", line 7, in <module>
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\__main__.py", line 471, in main
    main_real()
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\__main__.py", line 461, in main_real
    kicost(in_file=args.input, eda_name=args.eda,
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\kicost.py", line 251, in kicost
    query_part_info(parts, dist_list, currency)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\kicost.py", line 78, in query_part_info
    get_dist_parts_info(parts, dist_list, currency)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\distributors\__init__.py", line 50, in get_dist_parts_info
    distributor_class.get_dist_parts_info(parts, dist_list, currency)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\distributors\distributor.py", line 146, in get_dist_parts_info
    solved = api.query_part_info(parts, list(remaining), currency)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\distributors\api_nexar.py", line 635, in query_part_info
    api_nexar.fill_part_info(queries, distributors, currency, solved_dist)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\distributors\api_nexar.py", line 446, in fill_part_info
    result, no_offers = api_nexar.select_best_part(result, part, native_dists)
  File "C:\Users\craig\Documents\KiCad\6.0\3rdparty\Python39\site-packages\kicost\distributors\api_nexar.py", line 392, in select_best_part
    best_match = difflib.get_close_matches(manf, manufacturers.keys())[0]
IndexError: list index out of range
craigarno commented 1 year ago

This problem may have been a result of a part number which includes a ',' in the part number

NZH10C,115 https://www.digikey.com/en/products/detail/rochester-electronics-llc/NZH10C-115/15641970 https://www.mouser.com/ProductDetail/Nexperia/NZH10C115?qs=5DYmZrWuUEoyHVRX7wWPEg%3D%3D https://www.arrow.com/en/products/nzh10c115/nexperia?region=nac&utm_currency=USD&utm_keyword=NZH10C,115 https://www.lcsc.com/product-detail/Zener-Diodes_Nexperia-NZH10C-115_C551630.html https://www.tme.eu/en/details/nzh10c.115/smd-zener-diodes/nexperia/nzh10c-115/

When I escape the comma in the part number like this: NZH10C\,115 Nexar doesn't crash.

The clue was in the Spreadsheet, two entries for part D3 as KiCost tried to parse the partnumber two separate numbers. Escaping the comma allowed the entire number to be used in lookup.

I propose that parsing of the number field should happen in KiCost and commas escaped before submitting to all vendors; Digikey, Mouser, Nexar, Newark, TME, etc.

I wonder if different/improved error handling could also prevent this sort of crash?

set-soft commented 1 year ago

Hi @craigarno ! Try the above patch. The problem seems to be in the difflib returning 0 best matches. Now the code should take the first match if none is better than the others.