mirror of
https://github.com/jhbruhn/eurorack.git
synced 2025-03-15 02:55:49 +00:00
Add tools
This commit is contained in:
parent
e7d5877125
commit
49632d8cfc
2 changed files with 75 additions and 0 deletions
43
helpers/bomtool.py
Executable file
43
helpers/bomtool.py
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# coding=utf8
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import csv
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
package_remap = {
|
||||||
|
"R0603": "0603_R",
|
||||||
|
"C0603": "0603_C",
|
||||||
|
|
||||||
|
"SO08": "SOIC-8_150mil",
|
||||||
|
"SO14": "SOIC-14_150MIL"
|
||||||
|
}
|
||||||
|
|
||||||
|
value_remap = {
|
||||||
|
"TL072D": "TL072",
|
||||||
|
"TL074D": "TL074",
|
||||||
|
"1N4148-2": "1N4148"
|
||||||
|
}
|
||||||
|
|
||||||
|
in_file = open(sys.argv[1], 'r')
|
||||||
|
out_file = open(sys.argv[2], 'w')
|
||||||
|
|
||||||
|
reader = csv.DictReader(in_file, delimiter=';')
|
||||||
|
ordered_fieldnames = OrderedDict([('Comment', None), ('Designator', None), ('Footprint', None), ('LCSC Part #', None), ('LCSC Part Type', None)])
|
||||||
|
writer = csv.DictWriter(out_file, delimiter=',', quoting=csv.QUOTE_NONNUMERIC, fieldnames=ordered_fieldnames)
|
||||||
|
|
||||||
|
writer.writerow({'Comment': 'Comment', 'Designator': 'Designator', 'Footprint': 'Footprint', 'LCSC Part #': 'LCSC Part #', 'LCSC Part Type': 'LCSC Part Type'})
|
||||||
|
|
||||||
|
for row in reader:
|
||||||
|
names, value, package, num = [row['Parts'], row['Value'], row['Package'], row['Qty']]
|
||||||
|
package = package_remap.get(package, package)
|
||||||
|
value = value_remap.get(value, value)
|
||||||
|
namestring = ""
|
||||||
|
for name in names.split(','):
|
||||||
|
name = name.strip()
|
||||||
|
namestring += name+ ', '
|
||||||
|
namestring = namestring[:len(namestring) - 2]
|
||||||
|
writer.writerow({'Comment': value, 'Designator': namestring, 'Footprint': package, 'LCSC Part #': '', 'LCSC Part Type': ''})
|
||||||
|
|
||||||
|
in_file.close()
|
||||||
|
out_file.close()
|
32
helpers/mnbtool.py
Executable file
32
helpers/mnbtool.py
Executable file
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# coding=utf8
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import csv
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
in_t_file = open(sys.argv[1], 'r')
|
||||||
|
in_b_file = open(sys.argv[2], 'r')
|
||||||
|
out_file = open(sys.argv[3], 'w')
|
||||||
|
|
||||||
|
reader_t = csv.reader(in_t_file, dialect='excel-tab')
|
||||||
|
reader_b = csv.reader(in_b_file, dialect='excel-tab')
|
||||||
|
ordered_fieldnames = OrderedDict([('Designator', None), ('Mid X', None), ('Mid Y', None), ('Layer', None), ('Rotation', None)])
|
||||||
|
writer = csv.DictWriter(out_file, delimiter=',', quoting=csv.QUOTE_NONNUMERIC, fieldnames=ordered_fieldnames)
|
||||||
|
|
||||||
|
writer.writerow({'Designator': 'Designator', 'Mid X': 'Mid X', 'Mid Y': 'Mid Y', 'Layer': 'Layer', 'Rotation': 'Rotation'})
|
||||||
|
|
||||||
|
|
||||||
|
for reader in [reader_t, reader_b]:
|
||||||
|
layer = 'Top'
|
||||||
|
if reader == reader_b:
|
||||||
|
layer = 'Bottom'
|
||||||
|
|
||||||
|
for row in reader:
|
||||||
|
row = list(filter(None, row[0].split(' ')))
|
||||||
|
|
||||||
|
writer.writerow({'Designator': row[0], 'Mid X': row[1], 'Mid Y': row[2], 'Layer': layer, 'Rotation': row[3]})
|
||||||
|
|
||||||
|
in_t_file.close()
|
||||||
|
in_b_file.close()
|
||||||
|
out_file.close()
|
Loading…
Reference in a new issue