Warn if identical parts with different PNs #293

This commit is contained in:
andreika-git 2023-05-18 20:12:16 +03:00
parent 4b77ad9d21
commit 32e5adec5b
2 changed files with 27 additions and 3 deletions

View File

@ -35,6 +35,12 @@ def read_repl_file(csv_name, repl_base_path, replList):
subrow.append(row[3])
replList.append(subrow)
def printWarning(text):
print (text)
if warningFileName:
with open(warningFileName, "a") as wf:
wf.write(text + "\n")
if len(sys.argv) < 2:
print ("Error! Please specify a BOM file name.")
sys.exit(1)
@ -44,6 +50,9 @@ if len(sys.argv) > 2:
repl_csv = sys.argv[2]
repl_base_path = os.path.dirname(repl_csv)
if len(sys.argv) > 3:
warningFileName = sys.argv[3]
print ("Opening BOM file " + fileName + "...")
rows = OrderedDict()
@ -73,8 +82,7 @@ with open(fileName, 'rt') as f:
print ("* Error! Comment mismatch for the part #" + rowName + ": " + oldRow[0] + " != " + row[0])
sys.exit(2)
if oldRow[2] != row[2]:
print ("* Warning! Footprint mismatch for the part #" + rowName + ": " + oldRow[2] + " != " + row[2])
#sys.exit(3)
printWarning ("* Warning! Footprint mismatch for the part #" + rowName + ": " + oldRow[2] + " != " + row[2])
print ("* Duplicates found for " + rowName + " (" + row[0] + ")! Merging...")
row[1] = oldRow[1] + row[1]
rows[rowName] = row
@ -109,6 +117,20 @@ for r in replList:
print ("* Appending a new row for " + reDesignator + "...")
rows[rePartNumber] = [reComment, [reDesignator], reFootprint, rePartNumber]
print ("Checking for identical parts with different partnumbers...")
commentAndFootprint = OrderedDict()
for rowName in rows:
row = rows[rowName]
cf = row[0] + "_" + row[2]
if not row[3]:
continue
partName = (",".join(row[1])) if (type(row[1]) == list) else row[1]
if (cf in commentAndFootprint):
if (commentAndFootprint[cf][1] != row[3]):
printWarning ("* Warning! Identical parts " + partName + " and " + commentAndFootprint[cf][0] + " (" + cf + ") have different partnumbers: " + row[3] + " and " + commentAndFootprint[cf][1])
else:
commentAndFootprint[cf] = [partName, row[3]]
print ("Final checks...")
for rowName in rows:
row = rows[rowName]

View File

@ -53,6 +53,7 @@ board_img_top = board_misc_path_name + "-top.png"
board_img_bottom = board_misc_path_name + "-bottom.png"
board_img_outline = board_misc_path_name + "-outline.png"
board_img_components = board_misc_path_name + "-components.png"
warnings_path = board_path + "/warnings.log"
node_bin = "node"
rotations = "bin/jlc_kicad_tools/cpl_rotations_db.csv"
@ -351,7 +352,8 @@ print ("Post-processing BOM...")
try:
out = subprocess.check_output([sys.executable, "bin/process_BOM.py",
board_bom,
bom_replace_csv_path], stderr=subprocess.STDOUT)
bom_replace_csv_path,
warnings_path], stderr=subprocess.STDOUT)
print (out.decode('ascii'))
except subprocess.CalledProcessError as e:
print ("BOM processing error:\n" + e.output.decode('ascii'))