GPToolbox¶
GPToolbox is used as a base class to create GPTool wrappers for ENVI, IDL, and GSF Analytics.
-
class
envipyarclib.gptoolbox.
GPToolbox
(tasks=None, alias=None, imports_template=<string.Template object>, execute_template=<string.Template object>, parameter_templates=None)[source]¶ GPToolbox is used as a base class to create GPTool wrappers for ENVI, IDL, and GSF Analytics.
Parameters: - tasks – a list of tasks to map to GPTools where each task name is a GPTool in the toolbox.
- alias – The alias of the generated toolbox
- imports_template – The template string code for defining imports
- execute_template – The template string code for GPTool execution
- parameter_templates – The python package containing parameter templates. Templates must implement the envipyarclib.gptool.parameter.Template class.
-
create_toolbox
(filename)[source]¶ Creates a new Python toolbox where each task name is a GPTool in the toolbox.
Parameters: - filename – the filename of the generated toolbox
- service_name – The name of the ESE service containing the tasks. Only tasks from one service may be used.
- tasks – The list of tasks from the service to build as GPTools.
GPTool Parameter Builder¶
The GPTool Parameter Builder is responsible for creating code blocks to be placed into the main GPTool template. Each create method corresponds to a GPTool method that must be defined in order for it to be a valid tool. These methods implement the GetParameterInfo, UpdateParameter, and Execute methods of the GPTool Python class.
For example, to define a GPTool in a Python toolbox, start out with a class definition and implement the methods arcpy expects:
class myTool(Object):
def __init__(self):
self.label = "My Tool"
self.description = "Tool description"
self.canRunInBackground = True
def getParameterInfo(self):
# builder.create_param_info() goes here
def is Licensed(self):
return True
def updateParameters(self, parameters):
# builder.create_update_parameter goes here
def updateMessages(self, parameters):
return
def execute(self, parameters, messages):
# builder.create_pre_execute goes here
# submit job
# builder.create_post_execute goes here
-
class
envipyarclib.gptool.parameter.builder.
ParameterMap
[source]¶ Convenience class for holding a template map
-
exception
envipyarclib.gptool.parameter.builder.
UnknownDataTypeError
[source]¶ Error class for raising unknown datatypes
-
envipyarclib.gptool.parameter.builder.
convert_list
(in_list)[source]¶ Converts a list of strings to a printable list of object names
-
envipyarclib.gptool.parameter.builder.
create_param_info
(task_params, parameter_map)[source]¶ Builds the code block for the GPTool GetParameterInfo method based on the input task_params.
Parameters: task_params – A list of task parameters to map to GPTool parameters. Returns: A string representing the code block to the GPTool GetParameterInfo method.
-
envipyarclib.gptool.parameter.builder.
create_post_execute
(task_params, parameter_map)[source]¶ Builds the code block for the GPTool Execute method after the job is submitted based on the input task_params.
Parameters: task_params – A list of task parameters from the task info structure. Returns: A string representing the code block to the GPTool Execute method.
-
envipyarclib.gptool.parameter.builder.
create_pre_execute
(task_params, parameter_map)[source]¶ Builds the code block for the GPTool Execute method before the job is submitted based on the input task_params.
Parameters: task_params – A list of task parameters from the task info structure. Returns: A string representing the code block to the GPTool Execute method.
-
envipyarclib.gptool.parameter.builder.
create_update_parameter
(task_params, parameter_map)[source]¶ Builds the code block for the GPTool UpdateParameter method based on the input task_params.
Parameters: task_params – A list of task parameters from the task info structure. Returns: A string representing the code block to the GPTool UpdateParameter method.
GPTool Parameter Template¶
-
class
envipyarclib.gptool.parameter.template.
Template
(data_type)[source]¶ Interface class for mapping Task parameters to ArcGIS GPTool parameters.
-
default_value
()[source]¶ Defines the code block for this parameter data type in the GPTool GetParameterInfo if a default value exists.
Returns: Returns the string.Template object.
-
get_parameter
(task_param)[source]¶ Defines the code block for this parameter data type in the GPTool GetParameterInfo method. All code returned must begin with 2 indents. The template is substituted against the GP parameter dictionary.
Parameters: task_param – The task parameter information. Returns: Returns the string.Template object.
-
parameter_names
(task_param)[source]¶ Defines the code block for the parameter variable names in the GPTool GetParameterInfo method.
Parameters: task_param – The task parameter Returns: A list of string.Template objects representing the parameter variable names defined in get_parameter.
-
post_execute
()[source]¶ Defines the code block for this parameter data type in the GPTool Execute method after the task is executed.
Returns: Returns the the string.Template object
-