matflow.ActionRule#
- class matflow.ActionRule(rule=None, check_exists=None, check_missing=None, path=None, condition=None, cast=None, doc=None)#
Bases:
ActionRule
Class to represent a rule/condition that must be True if an action is to be included.
- Parameters:
rule (Rule) – The rule to apply.
check_exists (str) – A special rule that is enabled if this named attribute is present.
check_missing (str) – A special rule that is enabled if this named attribute is absent.
path (str) – Where to find the attribute to check.
condition (dict | ConditionLike) – A more complex condition to apply.
cast (str) – The name of a class to cast the attribute to before checking.
doc (str) – Documentation for this rule, if any.
Methods
Make an action rule that checks if a named attribute is present.
Make an action rule that checks if a named attribute is absent.
Make an instance of this class from JSON (or YAML) data.
Test if this rule holds for a particular iteration.
Serialize this object as a dictionary.
Serialize this object as an object structure that can be trivially converted to JSON.
Attributes
The rule to apply.
The action that contains this rule.
The command that is guarded by this rule.
- action#
The action that contains this rule.
- app = App(name='MatFlow', version='0.3.0a132')#
- classmethod check_exists(check_exists)#
Make an action rule that checks if a named attribute is present.
Parameter#
- check_exists: str
The path to the attribute to check for.
- classmethod check_missing(check_missing)#
Make an action rule that checks if a named attribute is absent.
Parameter#
- check_missing: str
The path to the attribute to check for.
- command#
The command that is guarded by this rule.
- classmethod from_json_like(json_like, shared_data=None)#
Make an instance of this class from JSON (or YAML) data.
- Parameters:
json_like (Union[Dict, List]) – The data to deserialise.
shared_data (Optional[Dict[str, ObjectList]]) – Shared context data.
- Return type:
The deserialised object.
- rule#
The rule to apply.
- test(element_iteration)#
Test if this rule holds for a particular iteration.
Parameter#
- element_iteration:
The iteration to apply this rule to.
- Parameters:
element_iteration (ElementIteration) –
- Return type:
- to_dict()#
Serialize this object as a dictionary.
- to_json_like(dct=None, shared_data=None, exclude=None, path=None)#
Serialize this object as an object structure that can be trivially converted to JSON. Note that YAML can also be produced from the result of this method; it just requires a different final serialization step.