-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkicad_bom_generator.py
50 lines (36 loc) · 1.1 KB
/
kicad_bom_generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
@package
Super configurable, and extensible BOM generator for KiCad.
Built by Michael Rouse at the Missouri S&T Solar Car Team
"""
import sys
import os
import glob
import importlib
import fnmatch
import Pipeline
import Arguments
import Config
import Logger
# Parse command line arguments and get configuration
args = Arguments.Parse()
# Path that the script is in
script_dir = os.path.dirname(os.path.realpath(__file__))
def load_modules(module_folder):
""" Loads all custom modules from a module folder """
found = glob.glob(script_dir + '/' + module_folder + '/*_' + module_folder.lower() + '.py')
for file in found:
name = os.path.basename(file).replace('.py', '') # Remove file extension
module = "{0}.{1}".format(module_folder, name)
Logger.Debug("Importing: {0}".format(module))
importlib.import_module(module)
# Load Middleware
load_modules("Middleware")
# Load Formatters
load_modules("Formatter")
# Load Afterware
load_modules("Afterware")
if __name__ == "__main__":
# Run the input file through the pipeline
Pipeline.RunOnValue(args.input_file)
os.remove(args.input_file)