2013-05-26 04:36:44 +00:00
|
|
|
#
|
|
|
|
# Example python script to generate an equivalent XML document from XML input
|
|
|
|
#
|
|
|
|
# Example: Round robin, XML to XML conversion
|
|
|
|
#
|
|
|
|
|
2013-09-01 17:49:01 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2013-05-26 04:36:44 +00:00
|
|
|
# Import the KiCad python helper module and the csv formatter
|
2013-09-01 17:49:01 +00:00
|
|
|
import kicad_netlist_reader
|
2013-05-26 04:36:44 +00:00
|
|
|
import sys
|
2013-09-01 17:49:01 +00:00
|
|
|
import pdb
|
|
|
|
|
2013-05-26 04:36:44 +00:00
|
|
|
|
|
|
|
# Generate an instance of a generic netlist, and load the netlist tree from
|
|
|
|
# the command line option. If the file doesn't exist, execution will stop
|
2013-09-01 17:49:01 +00:00
|
|
|
net = kicad_netlist_reader.netlist(sys.argv[1])
|
2013-05-26 04:36:44 +00:00
|
|
|
|
|
|
|
# Open a file to write to, if the file cannot be opened output to stdout
|
|
|
|
# instead
|
|
|
|
try:
|
|
|
|
f = open(sys.argv[2], 'w')
|
|
|
|
except IOError:
|
2013-09-01 17:49:01 +00:00
|
|
|
print( __file__, ":", e, file=sys.stderr)
|
2013-05-26 04:36:44 +00:00
|
|
|
f = stdout
|
|
|
|
|
2013-09-01 17:49:01 +00:00
|
|
|
print(net.formatXML(), file=f)
|