Welcome to clictk’s documentation!¶
clictk provides support for Common Toolkit’s Command Line Interface XML descriptions. It provides a Python model, can read and write XML description, argparse functionalities and calls CLIs.
Interface¶
-
class
clictk.model.Parameter(name, type, default, description=None, channel=None, values=None, flag=None, index=None, label=None, longflag=None, file_ext=None)[source]¶ Represents a CLI parameter.
You must either specify “flag” or “longflag” (or both) or “index”.
-
XML_FIELDS= ('name', 'index', 'flag', 'longflag', 'description', 'label', 'default', 'channel', 'hidden')¶
-
channel= None¶ - Specifies whether the parameter is an input or output parameter. Output
- parameters can for example specify file paths where to write output data (e.g. using the “image” element) or they can represent “simple return parameters”, indicated by providing an “index” of 1000. The current values of suche simple return parameters are not passed to the module during its execution. Rather, the module itself reports these parameter values during execution.
Type: str
-
default= None¶ - A default value for the parameter. The default must be a type that is compatible
- with the parameter type. The vector parameters are specified as comma separated values of the atomic parameter type.
Type: str
-
description= None¶ A brief description of the parameter.
Type: str
-
file_ext= None¶ acceptable file extensions
Type: str
-
flag= None¶ Type: str
-
static
from_xml_node(xml_node)[source]¶ constructs a CLI.Parameter from an xml node. :param xml_node: :type xml_node: xml.etree.ElementTree.Element :rtype: Executable.Parameter :return:
not documentated
Type: bool
-
index= None¶ An integer starting at 0, that specifies a module argument that has no flags.
The index value 1000 is reserved as a marker for output parameters (see the “channel” element) to indicate that this parameter is used to return results during the execution of this module and does not need to be set.
Type: int
-
label= None¶ label for parameter.
Type: str
-
longflag= None¶ long flag
Type: str
-
name= None¶ The unique name (within this module) of the parameter. This is only used internally. Pattern:
[_a-zA-Z][_a-zA-Z0-9]*
Type: str
-
type= None¶ type of this parameter (interger, float, ... )
Type: str
-
values= None¶ Enumerable values
Type: str
-
-
class
clictk.model.ParameterGroup(label=None, description=None, advanced=None, parameters=None)[source]¶ A list of multiple
Parameter.XML: Starts a group of parameters.
-
advanced= None¶ marks if this paramter section is marked as advanced.
- XML::
- This value is usually used in GUI generators to decide if the parameters belonging to this group should be initially hidden to the user or not.
Type: bool
-
description= None¶ - Description text of this parameter section
- <xsd:documentation>A description of this parameter group.</xsd:documentation>
Type: str
-
label= None¶ - Label text of the parameter section
- <xsd:documentation>A short string used as the label for this group.</xsd:documentation>
Type: str
-
parameters= None¶ Type: list[Parameter]
-
-
class
clictk.model.Executable(xml=None, executable=None, category=None, title=None, description=None, version=None, license=None, contributor=None, acknowledgements=None, documentation_url=None, parameter_groups=None)[source]¶ Represents an CLI executable.
- The root element for each module XML description. It must contain
- at least one “parameters” element.
-
XML_FIELDS= ('category', 'title', 'description', 'version', 'documentation_url', 'license', 'contributor', 'acknowledgements')¶
-
acknowledgements= None¶ Acknowledgements for funding agency, employer, colleague, etc
Type: str
-
category= None¶ Classifies the module (e.g. Filtering, Segmentation). The value can be a dot separated string to create category hierarchies.
Type: str
-
cmdline(**kwargs)[source]¶ Generates a valid command line call for the executable given by call arguments in kwargs :param kwargs: values to call the executable :return: the command line :rtype: list
-
contributor= None¶ The author(s) of the command line module :type: str
-
description= None¶ A detailed description of the modules purpose required for valid xml! :type: str
-
documentation_url= None¶ A URL pointing to a documentation or home page of the module.
Type: str
-
executable= None¶ Path to the executable
Type: str
-
static
from_etree(tree)[source]¶ Constructs an executable form a given ElementTree structure.
Parameters: tree (xml.etree.ElementTree.ElementTree) – Return type: Executable
-
license= None¶ The type of license or a URL containing the license :type: str
-
name¶
-
parameter_groups= None¶ list of
ParametersType: list[Parameters]
-
run(**kwargs)[source]¶ runs the executable
Parameters: kwargs – Returns: a dictionary with the output channels values
-
title= None¶ A human-readable name for the module required for valid xml! :type: str
-
version= None¶ The modules version number.
A suggested format is: major.minor.patch.build.status * vc: version controlled (pre-alpha), build can be a serial revision number, if any (like svn might have). * a: alpha * b: beta * rc: release candidate * fcs: first customer ship
Type: str