From 43ac90c1d21818a636336929671554302c6ea5b5 Mon Sep 17 00:00:00 2001 From: andreika-git Date: Thu, 6 Apr 2023 22:32:19 +0300 Subject: [PATCH] Full skip of BOM lines without JLC PN #287 --- bin/convert_BOM_mfr.py | 33 +++++++++++++++++++++++++++++++++ bin/process_board.py | 13 ++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 bin/convert_BOM_mfr.py diff --git a/bin/convert_BOM_mfr.py b/bin/convert_BOM_mfr.py new file mode 100644 index 0000000..ee38195 --- /dev/null +++ b/bin/convert_BOM_mfr.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +############################################################################################ +# Hellen-One: A manufacturer's BOM conversion script. +# (c) andreika +############################################################################################ + +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!") diff --git a/bin/process_board.py b/bin/process_board.py index 69365fd..842e59f 100644 --- a/bin/process_board.py +++ b/bin/process_board.py @@ -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