From f026d8cae6e070ebc432695125393b2dc76e8bdc Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 2 Jun 2018 15:06:20 +0300 Subject: [PATCH 1/3] - addded a new TclCommand that list the names of the system parameters. It is useful if we don't remember correctly the name of the system parameter or if we want to look for a certain system parameter as the list is big and it grows. --- tclCommands/TclCommandListSys.py | 43 ++++++++++++++++++++++++++++++++ tclCommands/__init__.py | 1 + 2 files changed, 44 insertions(+) create mode 100644 tclCommands/TclCommandListSys.py diff --git a/tclCommands/TclCommandListSys.py b/tclCommands/TclCommandListSys.py new file mode 100644 index 00000000..d0e2b9ca --- /dev/null +++ b/tclCommands/TclCommandListSys.py @@ -0,0 +1,43 @@ +from tclCommands.TclCommand import * + + +class TclCommandListSys(TclCommand): + """ + Tcl shell command to get the list of system variables + + example: + list_sys + """ + + # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon) + aliases = ['list_sys', 'listsys'] + + # Dictionary of types from Tcl command, needs to be ordered + arg_names = collections.OrderedDict([ + ]) + + # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value + option_types = collections.OrderedDict([ + + ]) + + # array of mandatory options for current Tcl command: required = {'name','outname'} + required = [] + + # structured help for current command, args needs to be ordered + help = { + 'main': "Returns the list of the names of system variables.\n" + "Note: Use get_sys command to get the value and set_sys command to set it.", + 'args': collections.OrderedDict([ + ]), + 'examples': [] + } + + def execute(self, args, unnamed_args): + """ + + :param args: + :param unnamed_args: + :return: + """ + return str([*self.app.defaults]) \ No newline at end of file diff --git a/tclCommands/__init__.py b/tclCommands/__init__.py index c1ffc809..bb646c84 100644 --- a/tclCommands/__init__.py +++ b/tclCommands/__init__.py @@ -26,6 +26,7 @@ import tclCommands.TclCommandInteriors import tclCommands.TclCommandIsolate import tclCommands.TclCommandJoinExcellon import tclCommands.TclCommandJoinGeometry +import tclCommands.TclCommandListSys import tclCommands.TclCommandMillHoles import tclCommands.TclCommandMirror import tclCommands.TclCommandNew From ddda4773e3ec61251da7275f791e6b1d26e6940d Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 2 Jun 2018 16:11:40 +0300 Subject: [PATCH 2/3] - added the possibility of selecting which system parameters to list starting with the letter(s) offered as argument. It's a way to narrow the list down. If no selection letters are offered it will list on screen the entire list of system parameters. --- tclCommands/TclCommandListSys.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tclCommands/TclCommandListSys.py b/tclCommands/TclCommandListSys.py index d0e2b9ca..179be874 100644 --- a/tclCommands/TclCommandListSys.py +++ b/tclCommands/TclCommandListSys.py @@ -14,6 +14,7 @@ class TclCommandListSys(TclCommand): # Dictionary of types from Tcl command, needs to be ordered arg_names = collections.OrderedDict([ + ('selection', str), ]) # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value @@ -27,10 +28,17 @@ class TclCommandListSys(TclCommand): # structured help for current command, args needs to be ordered help = { 'main': "Returns the list of the names of system variables.\n" - "Note: Use get_sys command to get the value and set_sys command to set it.", + "Without a parameter it will list all the system parameters. " + "As a parameter use first letter or first letters from the name " + "of the system variable.\n" + "In that case it will list only the system variables that starts with that string.\n" + "Main categories start with: gerber or excellon or geometry or cncjob or global.\n" + "Note: Use get_sys command to get the value and set_sys command to set it.\n", 'args': collections.OrderedDict([ ]), - 'examples': [] + 'examples': ['list_sys', + 'list_sys gerber', + 'list_sys cncjob'] } def execute(self, args, unnamed_args): @@ -40,4 +48,9 @@ class TclCommandListSys(TclCommand): :param unnamed_args: :return: """ - return str([*self.app.defaults]) \ No newline at end of file + if 'selection' in args: + argument = args['selection'] + print(argument) + return str([k for k in self.app.defaults.keys() if str(k).startswith(str(argument))]) + else: + return str([*self.app.defaults]) \ No newline at end of file From 21406fcccfcd971e89afbfbbe5933c4bf5cfdf22 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 2 Jun 2018 16:17:46 +0300 Subject: [PATCH 3/3] - some small corrections --- tclCommands/TclCommandListSys.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tclCommands/TclCommandListSys.py b/tclCommands/TclCommandListSys.py index 179be874..87d5a761 100644 --- a/tclCommands/TclCommandListSys.py +++ b/tclCommands/TclCommandListSys.py @@ -28,17 +28,18 @@ class TclCommandListSys(TclCommand): # structured help for current command, args needs to be ordered help = { 'main': "Returns the list of the names of system variables.\n" - "Without a parameter it will list all the system parameters. " - "As a parameter use first letter or first letters from the name " + "Without an argument it will list all the system parameters. " + "As an argument use first letter or first letters from the name " "of the system variable.\n" "In that case it will list only the system variables that starts with that string.\n" "Main categories start with: gerber or excellon or geometry or cncjob or global.\n" - "Note: Use get_sys command to get the value and set_sys command to set it.\n", + "Note: Use get_sys TclCommand to get the value and set_sys TclCommand to set it.\n", 'args': collections.OrderedDict([ ]), 'examples': ['list_sys', + 'list_sys ser' 'list_sys gerber', - 'list_sys cncjob'] + 'list_sys cncj'] } def execute(self, args, unnamed_args): @@ -50,7 +51,6 @@ class TclCommandListSys(TclCommand): """ if 'selection' in args: argument = args['selection'] - print(argument) return str([k for k in self.app.defaults.keys() if str(k).startswith(str(argument))]) else: return str([*self.app.defaults]) \ No newline at end of file