You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
850 B

  1. #
  2. # Example python script to generate an equivalent XML document from XML input
  3. #
  4. # Example: Round robin, XML to XML conversion
  5. #
  6. from __future__ import print_function
  7. # Import the KiCad python helper module and the csv formatter
  8. import kicad_netlist_reader
  9. import sys
  10. import pdb
  11. # Generate an instance of a generic netlist, and load the netlist tree from
  12. # the command line option. If the file doesn't exist, execution will stop
  13. net = kicad_netlist_reader.netlist(sys.argv[1])
  14. # Open a file to write to, if the file cannot be opened output to stdout
  15. # instead
  16. canOpenFile = True
  17. try:
  18. f = open(sys.argv[2], 'w')
  19. except IOError:
  20. e = "Can't open output file for writing: " + sys.argv[2]
  21. print( __file__, ":", e, sys.stderr)
  22. f = sys.stdout
  23. canOpenFile = False
  24. print(net.formatXML(), file=f)
  25. if not canOpenFile:
  26. sys.exit(1)