Full skip of BOM lines without JLC PN #287

This commit is contained in:
andreika-git 2023-04-06 22:32:19 +03:00
parent 8f6dd384d6
commit 43ac90c1d2
2 changed files with 45 additions and 1 deletions

33
bin/convert_BOM_mfr.py Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env python
############################################################################################
# Hellen-One: A manufacturer's BOM conversion script.
# (c) andreika <prometheus.pcb@gmail.com>
############################################################################################
from collections import OrderedDict
import csv, os, sys, re
if len(sys.argv) < 3:
print ("Error! Please specify input and output BOM file names.")
sys.exit(1)
bomFileName = sys.argv[1]
mfrBomFileName = sys.argv[2]
print ("Converting from BOM file " + bomFileName + " to " + mfrBomFileName + "...")
with open(bomFileName, 'rt') as f, open (mfrBomFileName, 'wt') as new_f:
reader = csv.reader(f, delimiter=',')
rowIdx = 0
for row in reader:
pn = row[3].strip()
# skip lines with empty P/N
if not pn:
continue
if rowIdx == 0:
writer = csv.writer(new_f, quoting=csv.QUOTE_NONE, quotechar='"', escapechar='', delimiter=',', lineterminator='\n')
elif rowIdx == 1:
writer = csv.writer(new_f, quoting=csv.QUOTE_ALL, quotechar='"', escapechar='', delimiter=',', lineterminator='\n')
writer.writerow(row)
rowIdx += 1
print ("Done!")

View File

@ -45,7 +45,8 @@ merged_gerber_path = board_path + "/gerber"
board_cfg_path = board_path + "/board.cfg"
board_place_path = board_path + "/board_place.txt"
board_tmp_path = merged_gerber_path + "/" + board_name + ".tmp"
board_bom = board_path_name + "-BOM.csv"
board_bom = board_misc_path_name + "-BOM.csv"
board_bom_mfr = board_path_name + "-BOM-JLC.csv"
board_cpl = board_path_name + "-CPL.csv"
board_img = board_path_name + ".png"
board_img_top = board_misc_path_name + "-top.png"
@ -356,6 +357,16 @@ except subprocess.CalledProcessError as e:
print ("BOM processing error:\n" + e.output.decode('ascii'))
sys.exit(2)
print ("Convert to the manufacturer's BOM...")
try:
out = subprocess.check_output([sys.executable, "bin/convert_BOM_mfr.py",
board_bom,
board_bom_mfr], stderr=subprocess.STDOUT)
print (out.decode('ascii'))
except subprocess.CalledProcessError as e:
print ("Mfr's BOM conversion error:\n" + e.output.decode('ascii'))
sys.exit(2)
print ("Merging Schematics...")
result = subprocess.call([sys.executable, "bin/python-combine-pdfs/python-combinepdf.py"]
+ schem_list