From c5b09696ab2cbf8107bce92767cdc10710bec7c2 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 13 May 2017 16:52:56 +0200 Subject: [PATCH] Eeschema bom scripts: move python scripts to eeschema/plugins/python_scripts and xsl scripts to subdir xsl_scripts. Python scripts are now installed (previously: were ignored by the make install command) --- eeschema/plugins/CMakeLists.txt | 29 ++-- .../plugins/python_scripts}/README-bom.txt | 0 .../bom_csv_grouped_by_value.py | 0 .../bom_csv_grouped_by_value_with_fp.py | 0 .../python_scripts}/bom_csv_sorted_by_ref.py | 0 .../bom_html_grouped_by_value.py | 2 +- .../bom_html_with_advanced_grouping.py | 2 +- .../python_scripts}/bom_sorted_by_ref.py | 2 +- .../python_scripts}/kicad_netlist_reader.py | 0 .../plugins/python_scripts}/round_robin.py | 0 .../python_scripts}/round_value_robin.py | 0 .../plugins/{ => xsl_scripts}/bom2csv.xsl | 0 .../{ => xsl_scripts}/bom2grouped_csv.xsl | 0 .../bom_with_title_block_2_csv.xsl | 0 .../netlist_form_OrcadPcb2.xsl | 0 .../netlist_form_cadstar-RINF.xsl | 0 .../netlist_form_cadstar.xsl | 0 .../netlist_form_pads-pcb.xsl | 0 scripts/bom-in-python/bom_html_by_value.py | 143 ------------------ 19 files changed, 23 insertions(+), 155 deletions(-) rename {scripts/bom-in-python => eeschema/plugins/python_scripts}/README-bom.txt (100%) rename {scripts/bom-in-python => eeschema/plugins/python_scripts}/bom_csv_grouped_by_value.py (100%) rename {scripts/bom-in-python => eeschema/plugins/python_scripts}/bom_csv_grouped_by_value_with_fp.py (100%) rename {scripts/bom-in-python => eeschema/plugins/python_scripts}/bom_csv_sorted_by_ref.py (100%) rename {scripts/bom-in-python => eeschema/plugins/python_scripts}/bom_html_grouped_by_value.py (97%) rename {scripts/bom-in-python => eeschema/plugins/python_scripts}/bom_html_with_advanced_grouping.py (98%) rename {scripts/bom-in-python => eeschema/plugins/python_scripts}/bom_sorted_by_ref.py (97%) rename {scripts/bom-in-python => eeschema/plugins/python_scripts}/kicad_netlist_reader.py (100%) rename {scripts/bom-in-python => eeschema/plugins/python_scripts}/round_robin.py (100%) rename {scripts/bom-in-python => eeschema/plugins/python_scripts}/round_value_robin.py (100%) rename eeschema/plugins/{ => xsl_scripts}/bom2csv.xsl (100%) rename eeschema/plugins/{ => xsl_scripts}/bom2grouped_csv.xsl (100%) rename eeschema/plugins/{ => xsl_scripts}/bom_with_title_block_2_csv.xsl (100%) rename eeschema/plugins/{ => xsl_scripts}/netlist_form_OrcadPcb2.xsl (100%) rename eeschema/plugins/{ => xsl_scripts}/netlist_form_cadstar-RINF.xsl (100%) rename eeschema/plugins/{ => xsl_scripts}/netlist_form_cadstar.xsl (100%) rename eeschema/plugins/{ => xsl_scripts}/netlist_form_pads-pcb.xsl (100%) delete mode 100644 scripts/bom-in-python/bom_html_by_value.py diff --git a/eeschema/plugins/CMakeLists.txt b/eeschema/plugins/CMakeLists.txt index 8fbed3c3cb..5cf34d8771 100644 --- a/eeschema/plugins/CMakeLists.txt +++ b/eeschema/plugins/CMakeLists.txt @@ -3,17 +3,28 @@ # See chapter 14 of eeschema.pdf -set( xsl_lst - bom2csv.xsl - bom2grouped_csv.xsl - netlist_form_cadstar-RINF.xsl - netlist_form_cadstar.xsl - netlist_form_OrcadPcb2.xsl - netlist_form_pads-pcb.xsl - bom_with_title_block_2_csv.xsl +set( XSL_SCRIPTS_LIST + xsl_scripts/bom2csv.xsl + xsl_scripts/bom2grouped_csv.xsl + xsl_scripts/netlist_form_cadstar-RINF.xsl + xsl_scripts/netlist_form_cadstar.xsl + xsl_scripts/netlist_form_OrcadPcb2.xsl + xsl_scripts/netlist_form_pads-pcb.xsl + xsl_scripts/bom_with_title_block_2_csv.xsl ) -install( FILES ${xsl_lst} +set( PYTHON_SCRIPTS_LIST + python_scripts/README-bom.txt + python_scripts/kicad_netlist_reader.py + python_scripts/bom_csv_grouped_by_value.py + python_scripts/bom_csv_grouped_by_value_with_fp.py + python_scripts/bom_csv_sorted_by_ref.py + python_scripts/bom_html_grouped_by_value.py + python_scripts/bom_html_with_advanced_grouping.py + python_scripts/bom_sorted_by_ref.py + ) + +install( FILES ${XSL_SCRIPTS_LIST} ${PYTHON_SCRIPTS_LIST} DESTINATION ${KICAD_PLUGINS} COMPONENT binary ) diff --git a/scripts/bom-in-python/README-bom.txt b/eeschema/plugins/python_scripts/README-bom.txt similarity index 100% rename from scripts/bom-in-python/README-bom.txt rename to eeschema/plugins/python_scripts/README-bom.txt diff --git a/scripts/bom-in-python/bom_csv_grouped_by_value.py b/eeschema/plugins/python_scripts/bom_csv_grouped_by_value.py similarity index 100% rename from scripts/bom-in-python/bom_csv_grouped_by_value.py rename to eeschema/plugins/python_scripts/bom_csv_grouped_by_value.py diff --git a/scripts/bom-in-python/bom_csv_grouped_by_value_with_fp.py b/eeschema/plugins/python_scripts/bom_csv_grouped_by_value_with_fp.py similarity index 100% rename from scripts/bom-in-python/bom_csv_grouped_by_value_with_fp.py rename to eeschema/plugins/python_scripts/bom_csv_grouped_by_value_with_fp.py diff --git a/scripts/bom-in-python/bom_csv_sorted_by_ref.py b/eeschema/plugins/python_scripts/bom_csv_sorted_by_ref.py similarity index 100% rename from scripts/bom-in-python/bom_csv_sorted_by_ref.py rename to eeschema/plugins/python_scripts/bom_csv_sorted_by_ref.py diff --git a/scripts/bom-in-python/bom_html_grouped_by_value.py b/eeschema/plugins/python_scripts/bom_html_grouped_by_value.py similarity index 97% rename from scripts/bom-in-python/bom_html_grouped_by_value.py rename to eeschema/plugins/python_scripts/bom_html_grouped_by_value.py index 59321dc9e3..80def66453 100644 --- a/scripts/bom-in-python/bom_html_grouped_by_value.py +++ b/eeschema/plugins/python_scripts/bom_html_grouped_by_value.py @@ -11,7 +11,7 @@ Ref, Quantity, Value, Part, Datasheet, Description, Vendor Command line: - python "pathToFile/bom_html_grouped_by_value.py" "%I" "%O.csv" + python "pathToFile/bom_html_grouped_by_value.py" "%I" "%O.html" """ from __future__ import print_function diff --git a/scripts/bom-in-python/bom_html_with_advanced_grouping.py b/eeschema/plugins/python_scripts/bom_html_with_advanced_grouping.py similarity index 98% rename from scripts/bom-in-python/bom_html_with_advanced_grouping.py rename to eeschema/plugins/python_scripts/bom_html_with_advanced_grouping.py index 47589aadab..a091351509 100644 --- a/scripts/bom-in-python/bom_html_with_advanced_grouping.py +++ b/eeschema/plugins/python_scripts/bom_html_with_advanced_grouping.py @@ -12,7 +12,7 @@ Ref, Quantity, Value, Part, Footprint, Description, Vendor Command line: - python "pathToFile/bom_with_advanced_grouping.py" "%I" "%O.csv" + python "pathToFile/bom_with_advanced_grouping.py" "%I" "%O.html" """ diff --git a/scripts/bom-in-python/bom_sorted_by_ref.py b/eeschema/plugins/python_scripts/bom_sorted_by_ref.py similarity index 97% rename from scripts/bom-in-python/bom_sorted_by_ref.py rename to eeschema/plugins/python_scripts/bom_sorted_by_ref.py index eb3f33fbdb..6dd28d5743 100644 --- a/scripts/bom-in-python/bom_sorted_by_ref.py +++ b/eeschema/plugins/python_scripts/bom_sorted_by_ref.py @@ -11,7 +11,7 @@ Fields are separated by tabs Command line: - python "pathToFile/bom_sorted_by_ref.py" "%I" "%O.csv" + python "pathToFile/bom_sorted_by_ref.py" "%I" "%O.txt" """ from __future__ import print_function diff --git a/scripts/bom-in-python/kicad_netlist_reader.py b/eeschema/plugins/python_scripts/kicad_netlist_reader.py similarity index 100% rename from scripts/bom-in-python/kicad_netlist_reader.py rename to eeschema/plugins/python_scripts/kicad_netlist_reader.py diff --git a/scripts/bom-in-python/round_robin.py b/eeschema/plugins/python_scripts/round_robin.py similarity index 100% rename from scripts/bom-in-python/round_robin.py rename to eeschema/plugins/python_scripts/round_robin.py diff --git a/scripts/bom-in-python/round_value_robin.py b/eeschema/plugins/python_scripts/round_value_robin.py similarity index 100% rename from scripts/bom-in-python/round_value_robin.py rename to eeschema/plugins/python_scripts/round_value_robin.py diff --git a/eeschema/plugins/bom2csv.xsl b/eeschema/plugins/xsl_scripts/bom2csv.xsl similarity index 100% rename from eeschema/plugins/bom2csv.xsl rename to eeschema/plugins/xsl_scripts/bom2csv.xsl diff --git a/eeschema/plugins/bom2grouped_csv.xsl b/eeschema/plugins/xsl_scripts/bom2grouped_csv.xsl similarity index 100% rename from eeschema/plugins/bom2grouped_csv.xsl rename to eeschema/plugins/xsl_scripts/bom2grouped_csv.xsl diff --git a/eeschema/plugins/bom_with_title_block_2_csv.xsl b/eeschema/plugins/xsl_scripts/bom_with_title_block_2_csv.xsl similarity index 100% rename from eeschema/plugins/bom_with_title_block_2_csv.xsl rename to eeschema/plugins/xsl_scripts/bom_with_title_block_2_csv.xsl diff --git a/eeschema/plugins/netlist_form_OrcadPcb2.xsl b/eeschema/plugins/xsl_scripts/netlist_form_OrcadPcb2.xsl similarity index 100% rename from eeschema/plugins/netlist_form_OrcadPcb2.xsl rename to eeschema/plugins/xsl_scripts/netlist_form_OrcadPcb2.xsl diff --git a/eeschema/plugins/netlist_form_cadstar-RINF.xsl b/eeschema/plugins/xsl_scripts/netlist_form_cadstar-RINF.xsl similarity index 100% rename from eeschema/plugins/netlist_form_cadstar-RINF.xsl rename to eeschema/plugins/xsl_scripts/netlist_form_cadstar-RINF.xsl diff --git a/eeschema/plugins/netlist_form_cadstar.xsl b/eeschema/plugins/xsl_scripts/netlist_form_cadstar.xsl similarity index 100% rename from eeschema/plugins/netlist_form_cadstar.xsl rename to eeschema/plugins/xsl_scripts/netlist_form_cadstar.xsl diff --git a/eeschema/plugins/netlist_form_pads-pcb.xsl b/eeschema/plugins/xsl_scripts/netlist_form_pads-pcb.xsl similarity index 100% rename from eeschema/plugins/netlist_form_pads-pcb.xsl rename to eeschema/plugins/xsl_scripts/netlist_form_pads-pcb.xsl diff --git a/scripts/bom-in-python/bom_html_by_value.py b/scripts/bom-in-python/bom_html_by_value.py deleted file mode 100644 index f77437ced8..0000000000 --- a/scripts/bom-in-python/bom_html_by_value.py +++ /dev/null @@ -1,143 +0,0 @@ -# -# Example python script to generate a BOM from a KiCad generic netlist -# -# 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, Symbol, footprint, Description, Vendor - - Command line: - python "pathToFile/bom_html_by_value.py" "%I" "%O.csv" -""" - - -from __future__ import print_function - -# Import the KiCad python helper module and the csv formatter -import kicad_netlist_reader -import sys - -# Start with a basic html template -html = """ - - - - - KiCad BOM grouped by value and footprint - - -

-

-

-

- - -
- - - """ - -def myEqu(self, other): - """myEqu is a more advanced equivalence function for components which is - used by component grouping. Normal operation is to group components based - on their Value, Library source, and Library part. - - In this example of a more advanced equivalency operator we also compare the - custom fields Voltage, Tolerance and Manufacturer as well as the assigned - footprint. If these fields are not used in some parts they will simply be - ignored (they will match as both will be empty strings). - - """ - result = True - if self.getValue() != other.getValue(): - result = False - elif self.getLibName() != other.getLibName(): - result = False - elif self.getPartName() != other.getPartName(): - result = False - elif self.getFootprint() != other.getFootprint(): - result = False -# elif self.getField("Tolerance") != other.getField("Tolerance"): -# result = False -# elif self.getField("Manufacturer") != other.getField("Manufacturer"): -# result = False -# elif self.getField("Voltage") != other.getField("Voltage"): -# result = False - - return result - -# Override the component equivalence operator - it is important to do this -# before loading the netlist, otherwise all components will have the original -# equivalency operator. -kicad_netlist_reader.comp.__equ__ = myEqu - -# Generate an instance of a generic netlist, and load the netlist tree from -# video.xml. If the file doesn't exist, execution will stop -net = kicad_netlist_reader.netlist(sys.argv[1]) - -# Open a file to write too, if the file cannot be opened output to stdout -# instead -try: - f = open(sys.argv[2], 'w') -except IOError: - e = "Can't open output file for writing: " + sys.argv[2] - print( __file__, ":", e, sys.stderr ) - f = sys.stdout - -components = net.getInterestingComponents() - -# Output a set of rows for a header providing general information -html = html.replace('', net.getSource()) -html = html.replace('', net.getDate()) -html = html.replace('', net.getTool()) -html = html.replace('', "Component Count:" + \ - str(len(components))) - -row = "Ref" + "Qnty" -row += "Value" -row += "Symbol" -row += "Footprint" -row += "Description" -row += "PartNumber" -row += "Vendor" - -html = html.replace('', row + "") - -# Get all of the components in groups of matching parts + values -# (see kicad_netlist_reader.py) -grouped = net.groupComponents(components) - -# Output all of the component information -for group in grouped: - refs = "" - - # Add the reference of every component in the group and keep a reference - # to the component so that the other data can be filled in once per group - for component in group: - if len(refs) > 0: - refs += ", " - refs += component.getRef() - c = component - - row = "" - row += "" + refs +"" - row += "" + str(len(group)) + "" - row += "" + c.getValue() + "" -# row += "" + c.getLibName() + ":" + c.getPartName() + "" - row += "" + c.getPartName() + "" - row += "" + c.getFootprint() + "" - row += "" + c.getDescription() + "" - row += "" + c.getField("PartNumber") + "" - row += "" + c.getField("Vendor") + "" - row += "" - - html = html.replace('', row + "") - -# Print the formatted html to output file -print(html, file=f)