TclCommandOpenExcellon.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from ObjectCollection import *
  2. from tclCommands.TclCommand import TclCommandSignaled
  3. class TclCommandOpenExcellon(TclCommandSignaled):
  4. """
  5. Tcl shell command to open an Excellon file.
  6. """
  7. # array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  8. aliases = ['open_excellon']
  9. # Dictionary of types from Tcl command, needs to be ordered.
  10. # For positional arguments
  11. arg_names = collections.OrderedDict([
  12. ('filename', str)
  13. ])
  14. # Dictionary of types from Tcl command, needs to be ordered.
  15. # For options like -optionname value
  16. option_types = collections.OrderedDict([
  17. ('outname', str)
  18. ])
  19. # array of mandatory options for current Tcl command: required = {'name','outname'}
  20. required = ['filename']
  21. # structured help for current command, args needs to be ordered
  22. help = {
  23. 'main': "Opens an Excellon file.",
  24. 'args': collections.OrderedDict([
  25. ('filename', 'Path to file to open.'),
  26. ('outname', 'Name of the resulting Excellon object.')
  27. ]),
  28. 'examples': []
  29. }
  30. def execute(self, args, unnamed_args):
  31. """
  32. execute current TCL shell command
  33. :param args: array of known named arguments and options
  34. :param unnamed_args: array of other values which were passed into command
  35. without -somename and we do not have them in known arg_names
  36. :return: None or exception
  37. """
  38. filename = args.pop('filename')
  39. filename = filename.replace(' ', '')
  40. args['plot'] = False
  41. self.app.open_excellon(filename, **args)