passing flake8

This commit is contained in:
Brendan Haines 2021-09-20 22:30:42 -06:00
parent 70d4551be1
commit 6dfe630e26
2 changed files with 48 additions and 1 deletions

View 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)

View File

@ -68,7 +68,8 @@ logger.info("Parsing JLCPCB stock...")
stock = parts_csv[parts_csv["Stock"] > 0] stock = parts_csv[parts_csv["Stock"] > 0]
# NOTES: # 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
resistors = stock[stock["First Category"] == "Resistors"].copy() resistors = stock[stock["First Category"] == "Resistors"].copy()