insert help section to function comment block
The help string is defined in the instrument YAML file and will be
inserted as a block comment after the function definition.
If no help string is defined, the string 'no help available' will be
placed there.
@@ -96,10 +96,15 @@ def generate_set_string(command, command_root):
command_string = " ".join((command_root, to_string(command["set"]))).strip()
kwargs_string, scpi_command = parse_command_string(command_string)
+ if 'help' not in command:
+ command['help'] = 'no help available'
+ command['help'] = command['help'].replace('\t', ' ')
+
function_string = \
"""def set_{:s}(self{:}):
+ \"\"\"{:s}\"\"\"
scpi_command = {:}
- self.write(scpi_command)""".format(command['name'], kwargs_string, scpi_command)
+ self.write(scpi_command)""".format(command['name'], kwargs_string, command['help'], scpi_command)
return function_string
@@ -108,11 +113,16 @@ def generate_set_values_string(command, command_root):
command_string = " ".join((command_root, to_string(command["set_values"]))).strip()
kwargs_string, scpi_command, data_variable = parse_write_values_string(command_string)
+ if 'help' not in command:
+ command['help'] = 'no help available'
+ command['help'] = command['help'].replace('\t', ' ')
+
function_string = \
"""def set_{:s}(self{:}):
+ \"\"\"{:s}\"\"\"
scpi_command = {:}
self.write_values(scpi_command, {:})""".format(
- command['name'], kwargs_string, scpi_command, data_variable)
+ command['name'], kwargs_string, command['help'], scpi_command, data_variable)
return function_string
@@ -121,6 +131,10 @@ def generate_query_string(command, command_root):
command_string = "? ".join((command_root, to_string(command["query"]))).strip()
kwargs_string, scpi_command = parse_command_string(command_string)
+ if 'help' not in command:
+ command['help'] = 'no help available'
+ command['help'] = command['help'].replace('\t', ' ')
+
converter = command.get('returns', "str")
valid_converters = ("int", "str", "float", "bool")
if converter not in valid_converters:
@@ -140,9 +154,10 @@ def generate_query_string(command, command_root):
function_string = \
"""def query_{:s}(self{:}):
+ \"\"\"{:s}\"\"\"
scpi_command = {:}
value = self.query(scpi_command){:}
- return value""".format(command['name'], kwargs_string, scpi_command, pre_line)
+ return value""".format(command['name'], kwargs_string, command['help'], scpi_command, pre_line)
return function_string
@@ -151,11 +166,16 @@ def generate_query_values_string(command, command_root):
command_string = "? ".join((command_root, to_string(command["query_values"]))).strip()
kwargs_string, scpi_command = parse_command_string(command_string)
+ if 'help' not in command:
+ command['help'] = 'no help available'
+ command['help'] = command['help'].replace('\t', ' ')
+
function_string = \
"""def query_{:s}(self{:}):
+ \"\"\"{:s}\"\"\"
scpi_command = {:}
return self.query_values(scpi_command)""".format(
- command['name'], kwargs_string, scpi_command)
+ command['name'], kwargs_string, command['help'], scpi_command)
return function_string
