I continue my quest to document the MakeDigikeyBOM Python package I built.
The goal of this post is to familiarize us with the structure and purpose of the MakeDigikeyBom Python package and individual modules.
Thanks to Those That Went Before
As I noted in my previous post, I could not have gotten this far this quickly without the prior work of debvisme(xesscorp). He is the author of Kicost – Python that “build(s) cost spreadsheet for a Kicad project.” Kicost is well worth checking out. The GitHub location is here.
The MakeDigikeyBom Python project is located at this GitHub location.
I am self-taught when it comes to making flowcharts. I mention this because flowcharts I make don’t conform to a standard. This may make them more difficult for you to read. I apologize for that. However, I find the method I use to work for me.
Here is the flow chart of MakeDigikeyBOM at the highest level:
I have built two (well, actually three) Python files:
- __main__.py : This is where the majority of the high level command/control happens.
- makeDigikeyBOM.py: Takes the bom2csv and JellyBeanPartNumbers files and creates a MadeDigikeyBOM.csv file or a list of errors that must be fixed in either the bom2csv or JellyBeanPartNumbers files before the MadeDigikeyBOM.csv files can be generated.
- __init__.py: I put this in because it identifies a bunch of Python files as a Package (at least in Eclipse). I don’t know enough about Python to use it to an advantage.
The first thing is to gather user input. The pieces of info include:
- The full name of the bom2csv file. The bom2csv file was discussed in a previous post.
- The full name of the csv file that contains the jellybean parts. As with the bom2csv file, the jellybean parts file was discussed in a previous post.
- The directory path where MadeDigikeyBOM.csv will be written.
- Currently the “num_processes” field is not used. I got this field from the Kicost Python script and thought implementing is probably a good idea. Having this input argument is a placeholder for a potential future feature.
Since I run Python within the Eclipse environment, I enter arguments to MakeDigikeyBOM through the debug/run configurations. Here are the files I used:
The code in __main__.py checks to see if the bom2csv and jelly bean parts files exist. The script exists if either file does not exist.
If the files exist and the directory to contain MadeDigikeyBOM.csv exist, the __main__.py calls into makeDigikeyBOM() which is in the makeDigikeyBOM.py file.
That’s all there is to the high level part of the code.
In the next post I’ll cover the makeDIgikeyBOM.py file.