Transforms
- class helix.transform.Transform(*args, **kwargs)
A common base class for all transforms.
- TYPE_SOURCE = 'source'
A source-to-source transformation.
Setting
Transform.typetoTYPE_SOURCEindicates to Blueprints that this Transform should be fed source files and should produce modified source files.
- TYPE_ARTIFACT = 'artifact'
An artifact-to-artifact transformation.
Setting
Transform.typetoTYPE_ARTIFACTindicates to Blueprints that this Transform should be fed built artifacts and should produce modified built artifacts.
- property configuration
Parsed configuration parameters.
This is populated by the
configuremethod, controlled by theoptionsparameter. If this has not yet been configured, this raises aNotConfiguredexception.
- configure(**kwargs)
Parse configuration data passed as kwargs.
Configuration values taken from
optionswill be passed to this function as kwargs. This function is responsible for parsing and storing those configuration options and storing them inconfiguration.- Parameters:
**kwargs – Arbitrary keyword arguments corresponding to fields in
options
Note
Although it is possible to pass values of varying types to this method, it is recommended that code which makes use of configuration parameters assumed that they are a string, since configuration parameters parsed from command line arguments and configuration files will be passed as strings.
- property configured
Indicates if this has been configured.
This attribute is set
Trueby theconfiguremethod. Components are reconfigurable, soconfiguremay still be called ifconfiguredisTrue.A Configurable with no configuration options is considered to be already configured.
- dependencies = []
A list of external dependencies which must be installed.
This list is optional, but must consist of zero or more instances of
Dependency(or subclasses) which may be installed by users.
- abstract property description
- classmethod install(verbose=False)
Install all dependencies.
This reruns dependency installation regardless of if it has been installed already. This should be safe because of the requirement that dependency installation methods be repeatable but can be inefficient. Users can check the
installed()method to determine if the installation should be rerun.- Parameters:
verbose (bool) – Verbosity.
- classmethod installed()
Check if all dependencies have been installed.
- Returns:
Trueif all dependencies have been installed already, andFalseotherwise.
- abstract property name
A simple name.
Names should consist of [a-z-]. Make use of the
verbose_nameproperty if you would like a pretty-printable version of this name.
- options = {}
A dictionary of configurable options and default values.
This defines which options which may be edited with a call to
configure.Example
A subclass with both required and default parameters may be defined as:
options = { "server": {}, "port": {"default": 1337} }
- classmethod string()
- supported(source)
Check if the given source is supported.
This method is optional - the default behavior is to assume all sources are suppored.
- Parameters:
source (str) – The source material for this tranformation.
- Returns:
Trueif the target is supported by this transform,Falseotherwise.
- tags = ()
An optional iterable of human-readable tag tuples.
Tags may represent family or component groupings and are fairly loosely defined.
Example
An
APT29/SEDINTsample may be defined as(("family", "APT29"), ("sample", "SEDINT"))
- abstract property type
A short type descriptor.
This should be set to some constant (a short string) defined in some common location.
- validate_configuration()
Custom option validation code.
This optional method may be implemented on subclasses to provide custom configuration validation and is called by the
configuremethod. If invalid configuration is detected, this method should raiseConfigurationError. Parsed configuration values are stored inconfigurationby the time this is called.
- abstract property verbose_name
Verbose name for pretty printing.
- abstract property version
A version number.
This should be a string using Semantic Versioning.
- abstract transform(source, destination)
Apply this transform.
Applies this transform to the given
sourceand writes the output todestination. If this transform expects configuration, this method should raise exceptions ifconfiguredisFalsewhen this is called.- Parameters:
source (str) – The source material for this tranformation.
destination (str) – The destination to write the output of this transformation.