-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathExportBOM.py
executable file
·28 lines (25 loc) · 978 Bytes
/
ExportBOM.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
#!/usr/bin/env python3
import argparse
import itertools
from collections import namedtuple
from ODBPy.Components import *
from XLSXUtils import *
ComponentInfo = namedtuple("ComponentInfo", ["Name", "Value", "MPN"])
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("directory", help="ODB++ directory to read")
parser.add_argument("-o","--outfile", default="BOM.xlsx", help="XLSX file to write")
args = parser.parse_args()
# Parse components (top and bot)
components = read_components(args.directory)
# Remap by component name
all_components = [
ComponentInfo(
component.name,
component.properties.get("Value", ""),
component.properties.get("Name", "")
)
for component in itertools.chain(components.top.values(), components.bot.values())
]
print(f'Found {len(all_components)} components')
namedtuples_to_xlsx(args.outfile, all_components)