sparkmicro / Ki-nTree

Fast part creation for KiCad and InvenTree
GNU General Public License v3.0
171 stars 31 forks source link

Categories map for other supplier like TME. #214

Closed NightSkySK closed 4 months ago

NightSkySK commented 4 months ago

I would like to contribute to the project to help build categories and parametric mapping for other suppliers than Digikey. I've started with TME categories mapping. Can someone help to confirm if I'm going in the right direction with this mapping:

here is the sample of capacitor mapping in tme_categories.yaml

Capacitors:
  Aluminium:
  - Electrolytic capacitors
  - SMD electrolytic capacitors
  - THT electrolytic capacitors
  - SNAP-IN electrolytic capacitors
  Ceramic:
  - MLCC capacitors
  - MLCC SMD capacitors
  - MLCC THT capacitors
  - MLCC array capacitors
  - Ceramic capacitors
  - THT ceramic capacitors
  Polymer:
  - Polymer and Hybrid Capacitors
  - SMD Polymer Capacitors
  - THT Polymer Capacitors
  - SMD Hybrid Capacitors
  - THT Hybrid Capacitors
  - Polymer - tantalum capacitors
  Super Capacitors:
  - Supercapacitors
  Tantalum:
  - Tantalum capacitors
  - SMD tantalum capacitors
  - THT tantalum capacitors

so let's take as example https://www.tme.eu/pl/en/details/0805b104k500ct/mlcc-smd-capacitors/walsin/ it belong to the category: Passives/Capacitors/MLCC capacitors/MLCC SMD capacitors

Is it correctly mapped in the above yaml file?

As I checked the source code kintree/database/inventree_interface.py method is get_categories_from_supplier_data is currently fixed to check only digikey categories mapping: category_map = config_interface.load_supplier_categories_inversed(supplier_config_path=settings.CONFIG_DIGIKEY_CATEGORIES)

so to make it work with some other supplier categories mapping there need to be made some more changes here, isn't it?

T0jan commented 4 months ago

Hi @NightSkySK,

As far as I am aware the category maps aren't really used anymore except for some publishing tests we are doing. If you want to map parameters you can do this in the supplier_parameters.yaml only for now. The supplier specific mappings are not loaded or used rn, but feel free to add this function.

eeintech commented 4 months ago

The "auto-match" supplier category feature is quite old and I didn't give it much love as the GUI now let's you find InvenTree categories quite easily, at least in my opinion. If you really wish to get that magic for another supplier, it should be quite easy to add the supplier as an input parameter to the get_categories_from_supplier_data function and load the category_map accordingly. What you have in your file seems correct at first glance.

NightSkySK commented 4 months ago

I will follow @T0jan recommendation to focus on supplier_parameters.yaml first, as that will give more benefits. After I look closer to the "auto-match" supplier category feature it becomes obvious that choosing a category from drop-down list is quite user-friendly as is.