Fix minor issues. Fix some outdated and broken BOM python scripts. Add info in BOM python scripts.
BOM dialog: remove a not very useful button, and merge its function with an other (not perfect, need more work) Add message box to show info added in BOM python scripts (See scripts/bom-in-python/README-bom.txt about this info)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
bom_?.py are some python scripts which read a generic xml netlist from eeschema,
|
||||
and create a bom.
|
||||
|
||||
All examples use ky_generic_netlist_reader.py, which is a python utility to read
|
||||
All examples use ky_netlist_reader.py, which is a python utility to read
|
||||
and parse this generic xml netlist and create the corresponding data
|
||||
used to build the bom.
|
||||
|
||||
@@ -12,3 +12,27 @@ python bom_example?.py <netlist name> <bom list netname>
|
||||
|
||||
See Eeschema doc, chapter 14 for info about the generic xml netlist format,
|
||||
and how to run a script from Eeschema to create a customized netlist or BOM.
|
||||
|
||||
If the python comment
|
||||
"""
|
||||
@package
|
||||
some comments
|
||||
"""
|
||||
is added to the begining of the python script, the comment will be displayed
|
||||
in Eescheam, in the BOM dialog
|
||||
|
||||
For instance:
|
||||
"""
|
||||
@package
|
||||
Generate a HTML BOM list.
|
||||
Components are sorted and grouped by value
|
||||
Fields are (if exist)
|
||||
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
|
||||
"""
|
||||
|
||||
displays:
|
||||
Generate a HTML BOM list.
|
||||
Components are sorted and grouped by value
|
||||
Fields are (if exist)
|
||||
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
|
||||
in BOM dialog
|
||||
|
||||
@@ -4,6 +4,15 @@
|
||||
# Example: Sorted and Grouped HTML BOM with more advanced grouping
|
||||
#
|
||||
|
||||
"""
|
||||
@package
|
||||
Generate a HTML BOM list.
|
||||
Components are sorted and grouped by value
|
||||
Fields are (if exist)
|
||||
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# Import the KiCad python helper module and the csv formatter
|
||||
@@ -74,8 +83,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
|
||||
try:
|
||||
f = open(sys.argv[2], 'w')
|
||||
except IOError:
|
||||
e = "Can't open output file for writing: " + sys.argv[2]
|
||||
print(__file__, ":", e, file=sys.stderr)
|
||||
f = stdout
|
||||
f = sys.stdout
|
||||
|
||||
# Output a set of rows for a header providing general information
|
||||
html = html.replace('<!--SOURCE-->', net.getSource())
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
#
|
||||
# Example python script to generate a BOM from a KiCad generic netlist
|
||||
#
|
||||
# Example: Tab delimited list (The same as std output) Ungrouped
|
||||
#
|
||||
"""
|
||||
@package
|
||||
Generate a csv list file.
|
||||
Components are sorted by ref and grouped by value
|
||||
One component per line
|
||||
Fields are (if exist)
|
||||
Ref, Quantity, value, Part, 'footprint', 'Description', 'Vendor'
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
@@ -20,8 +26,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
|
||||
try:
|
||||
f = open(sys.argv[2], 'w')
|
||||
except IOError:
|
||||
print(__file__, ":", e, file=sys.stderr)
|
||||
f = stdout
|
||||
e = "Can't open output file for writing: " + sys.argv[2]
|
||||
print(__file__, ":", e, sys.stderr)
|
||||
f = sys.stdout
|
||||
|
||||
# Create a new csv writer object to use as the output formatter, although we
|
||||
# are created a tab delimited list instead!
|
||||
|
||||
@@ -4,6 +4,15 @@
|
||||
# Example: Ungrouped (One component per row) CSV output
|
||||
#
|
||||
|
||||
"""
|
||||
@package
|
||||
Generate a csv list file.
|
||||
Components are sorted by ref and grouped by value
|
||||
One component per line
|
||||
Fields are (if exist)
|
||||
Ref, value, Part, footprint, Datasheet, Manufacturer, Vendor
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# Import the KiCad python helper module
|
||||
@@ -20,8 +29,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
|
||||
try:
|
||||
f = open(sys.argv[2], 'w')
|
||||
except IOError:
|
||||
print(__file__, ":", e, file=sys.stderr)
|
||||
f = stdout
|
||||
e = "Can't open output file for writing: " + sys.argv[2]
|
||||
print( __file__, ":", e, sys.stderr )
|
||||
f = sys.stdout
|
||||
|
||||
# Create a new csv writer object to use as the output formatter
|
||||
out = csv.writer(f, lineterminator='\n', delimiter=',', quotechar="\"", quoting=csv.QUOTE_ALL)
|
||||
|
||||
@@ -27,7 +27,7 @@ try:
|
||||
f = open(sys.argv[2], 'w')
|
||||
except IOError:
|
||||
e = "Can't open output file for writing: " + sys.argv[2]
|
||||
print(__file__, ":", e, file=sys.stderr)
|
||||
print( __file__, ":", e, sys.stderr )
|
||||
f = sys.stdout
|
||||
|
||||
# subset the components to those wanted in the BOM, controlled
|
||||
@@ -46,7 +46,7 @@ columnset = compfields | partfields # union
|
||||
columns = ['Item', 'Qty', 'Reference(s)', 'Value', 'LibPart', 'Footprint', 'Datasheet'] + sorted(list(columnset))
|
||||
|
||||
# Create a new csv writer object to use as the output formatter
|
||||
out = csv.writer(f, lineterminator='\n', delimiter=',', quotechar='\"', quoting=csv.QUOTE_MINIMAL)
|
||||
out = csv.writer( f, lineterminator='\n', delimiter=',', quotechar='\"', quoting=csv.QUOTE_MINIMAL )
|
||||
|
||||
# override csv.writer's writerow() to support utf8 encoding:
|
||||
def writerow( acsvwriter, columns ):
|
||||
|
||||
@@ -4,6 +4,15 @@
|
||||
# Example: Sorted and Grouped HTML BOM with more advanced grouping
|
||||
#
|
||||
|
||||
"""
|
||||
@package
|
||||
Generate a HTML BOM list.
|
||||
Components are sorted and grouped by ref
|
||||
Fields are (if exist)
|
||||
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# Import the KiCad python helper module and the csv formatter
|
||||
@@ -74,8 +83,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
|
||||
try:
|
||||
f = open(sys.argv[2], 'w')
|
||||
except IOError:
|
||||
print(__file__, ":", e, file=sys.stderr)
|
||||
f = stdout
|
||||
e = "Can't open output file for writing: " + sys.argv[2]
|
||||
print( __file__, ":", e, sys.stderr )
|
||||
f = sys.stdout
|
||||
|
||||
components = net.getInterestingComponents()
|
||||
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
#
|
||||
# Example: Sorted and Grouped HTML BOM
|
||||
#
|
||||
"""
|
||||
@package
|
||||
Generate a HTML BOM list.
|
||||
Components are sorted by ref and grouped by value
|
||||
Fields are (if exist)
|
||||
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
@@ -39,8 +46,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
|
||||
try:
|
||||
f = open(sys.argv[2], 'w')
|
||||
except IOError:
|
||||
e = "Can't open output file for writing: " + sys.argv[2]
|
||||
print(__file__, ":", e, file=sys.stderr)
|
||||
f = stdout
|
||||
f = sys.stdout
|
||||
|
||||
components = net.getInterestingComponents()
|
||||
|
||||
@@ -51,7 +59,8 @@ html = html.replace('<!--TOOL-->', net.getTool())
|
||||
html = html.replace('<!--COMPCOUNT-->', "<b>Component Count:</b>" + \
|
||||
str(len(components)))
|
||||
|
||||
row = "<tr><th style='width:640px'>Ref</th>" + "<th>Qnty</th>"
|
||||
row = "<tr><th style='width:640px'>Ref</th>"
|
||||
row += "<th>Qnty</th>"
|
||||
row += "<th>Value</th>" + "<th>Part</th>" + "<th>Datasheet</th>"
|
||||
row += "<th>Description</th>" + "<th>Vendor</th></tr>"
|
||||
|
||||
@@ -74,10 +83,11 @@ for group in grouped:
|
||||
c = component
|
||||
|
||||
row = "<tr><td>" + refs +"</td><td>" + str(len(group))
|
||||
row += "</td><td>" + c.getValue() + "</td><td>" + c.getLibName() + ":"
|
||||
row += c.getPartName() + "</td><td>" + c.getDatasheet() + "</td><td>"
|
||||
row += c.getDescription() + "</td><td>" + c.getField("Vendor")
|
||||
row += "</td></tr>"
|
||||
row += "</td><td>" + c.getValue()
|
||||
row += "</td><td>" + c.getLibName() + ":" + c.getPartName()
|
||||
row += "</td><td>" + c.getDatasheet()
|
||||
row += "</td><td>" + c.getDescription()
|
||||
row += "</td><td>" + c.getField("Vendor")+ "</td></tr>"
|
||||
|
||||
html = html.replace('<!--TABLEROW-->', row + "<!--TABLEROW-->")
|
||||
|
||||
|
||||
@@ -7,6 +7,15 @@
|
||||
# is due to be deprecated in 3.0+ soon
|
||||
#
|
||||
|
||||
"""
|
||||
@package
|
||||
Generate a HTML BOM list.
|
||||
Components are sorted and grouped by value
|
||||
Fields are (if exist)
|
||||
Ref, Quantity, Value, Part, Datasheet, Description, Vendor
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import xml.sax as sax
|
||||
|
||||
@@ -21,7 +21,8 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
|
||||
try:
|
||||
f = open(sys.argv[2], 'w')
|
||||
except IOError:
|
||||
print( __file__, ":", e, file=sys.stderr)
|
||||
f = stdout
|
||||
e = "Can't open output file for writing: " + sys.argv[2]
|
||||
print( __file__, ":", e, sys.stderr)
|
||||
f = sys.stdout
|
||||
|
||||
print(net.formatXML(), file=f)
|
||||
|
||||
@@ -64,8 +64,9 @@ net = kicad_netlist_reader.netlist(sys.argv[1])
|
||||
try:
|
||||
f = open(sys.argv[2], 'w')
|
||||
except IOError:
|
||||
e = "Can't open output file for writing: " + sys.argv[2]
|
||||
print(__file__, ":", e, file=sys.stderr)
|
||||
f = stdout
|
||||
f = sys.stdout
|
||||
|
||||
for c in net.components:
|
||||
c.checkvalue()
|
||||
|
||||
Reference in New Issue
Block a user