passing flake8
This commit is contained in:
parent
70d4551be1
commit
6dfe630e26
46
scripting/plugins/BomGeneration/BomGeneration.py
Normal file
46
scripting/plugins/BomGeneration/BomGeneration.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
"""
|
||||
To find best matches regardless of previous matches:
|
||||
python pathToFile/BomGeneration.py "%I" "%O.csv"
|
||||
To keep previous matches when possible:
|
||||
python pathToFile/BomGeneration.py "%I" "%O.csv" %O.csv"
|
||||
"""
|
||||
|
||||
import kicad_netlist_reader
|
||||
import csv
|
||||
import sys
|
||||
import argparse
|
||||
import numpy as np
|
||||
import requests
|
||||
|
||||
net = kicad_netlist_reader.netlist(sys.argv[1])
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("input", help="Input .xml netlist")
|
||||
parser.add_argument("output", help="Output .csv file path")
|
||||
parser.add_argument(
|
||||
"previous",
|
||||
default=None,
|
||||
nargs="?",
|
||||
help="Previous output. If provided, any matches from previous which are still valid will be retained",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.input, "r") as infile:
|
||||
old = ""
|
||||
if args.previous:
|
||||
with open(args.previous, "r") as oldfile:
|
||||
old = oldfile.read()
|
||||
|
||||
# TODO: parse old
|
||||
|
||||
# jlcparts = requests.get(f"https://jlcpcb.com/componentSearch/uploadComponentInfo")
|
||||
|
||||
comments = [[]]
|
||||
header = ["manufacturer", "manufacturer_part_number", "quantity", "designators"]
|
||||
data = [["dummy", "dpn", 2, "U1 U4"]]
|
||||
|
||||
with open(args.output, "w", newline="") as outfile:
|
||||
writer = csv.writer(outfile, delimiter=",", quotechar="'", quoting=csv.QUOTE_MINIMAL)
|
||||
writer.writerows(comments)
|
||||
writer.writerow(header)
|
||||
writer.writerows(data)
|
|
@ -68,7 +68,8 @@ logger.info("Parsing JLCPCB stock...")
|
|||
stock = parts_csv[parts_csv["Stock"] > 0]
|
||||
|
||||
# NOTES:
|
||||
# - if something has tolerance specified as absolute, "Value" may be wrong but "Tolerance" will be NA so it will be dropped
|
||||
# if something has tolerance specified as absolute,
|
||||
# "Value" may be wrong but "Tolerance" will be NA so it will be dropped
|
||||
|
||||
# resistors
|
||||
resistors = stock[stock["First Category"] == "Resistors"].copy()
|
||||
|
|
Loading…
Reference in New Issue
Block a user