Utility methods¶
- mtrchk.org.momotor.base.checklet.legacy.convert_legacy_selector(selector, *, option_name=None)¶
Convert a possible legacy selector (used by the base package prior to version 2.0.0) into a modern momotor-engine-options selector. If the selector is already in modern syntax, it is returned unchanged, otherwise a deprecation warning is logged and the selector is converted to modern syntax.
- Parameters:
- Return type:
- Returns:
A modern selector.
Note
The syntax described here is deprecated. Use the modern syntax as documented here.
The selector syntax was [ <condition> ][
:<result_id> ].Legacy selectors used the following syntax:
passTrue if outcome ==
passfailTrue if outcome ==
failerrorTrue if outcome ==
errorprop[x]Property x is True
prop[x]?Property x exists
prop[x]==0Property x equals 0
prop[x]>0Property x is greater than 0
prop[x]>=0Property x is greater than or equals 0
prop[x]<0Property x is less than 0
prop[x]<=0Property x is less than or equals 0
To invert the check, prefix with
not-:not-passTrue if outcome !=
passnot-prop[x]==0True if property x does not equal 0
If no <result_id> is provided or it equals
%all, all steps must match the condition. If <result_id> equals%any, any step can match the condition, otherwise all steps with given id must match the condition.<result id> can contain wildcards and
$task references, seeresult_query()for details.>>> convert_legacy_selector('pass') 'pass'
>>> convert_legacy_selector('pass:#all') '%all pass'
>>> convert_legacy_selector('pass#%all') '%all pass'
>>> convert_legacy_selector('pass:#any') '%any pass'
>>> convert_legacy_selector('pass#%any') '%any pass'
>>> convert_legacy_selector('pass:step-id') 'pass[#step-id]'
>>> convert_legacy_selector('pass#step-id') 'pass[#step-id]'
>>> convert_legacy_selector('prop[name]') 'prop[:name]'
>>> convert_legacy_selector('prop[name]:#any') '%any prop[:name]'
>>> convert_legacy_selector('prop[name]#%any') '%any prop[:name]'
>>> convert_legacy_selector('prop[name]:step-id') 'prop[#step-id:name]'
>>> convert_legacy_selector('prop[name]#step-id') 'prop[#step-id:name]'
>>> convert_legacy_selector('prop[name]?') 'prop[:name]?'
>>> convert_legacy_selector('prop[name]==0') 'prop[:name]==0'
>>> convert_legacy_selector('prop[name]?#step-id') 'prop[#step-id:name]?'
>>> convert_legacy_selector('prop[name]==0#step-id') 'prop[#step-id:name]==0'
>>> convert_legacy_selector('prop[name]==1.0#step-id') 'prop[#step-id:name]==1.0'
>>> convert_legacy_selector('prop[name]==1e10#step-id') 'prop[#step-id:name]==1e10'
>>> convert_legacy_selector('prop[name]==test#step-id') "prop[#step-id:name]=='test'"
>>> convert_legacy_selector('not-pass#step-id') 'not-pass[#step-id]'
>>> convert_legacy_selector('not-prop[name]#step-id') '%not prop[#step-id:name]'
>>> convert_legacy_selector('not-prop[name]#%any') '%notany prop[:name]'
- mtrchk.org.momotor.base.checklet.legacy.split_legacy_selector(selector)¶
Split a legacy selector into a condition and an id_query.
- mtrchk.org.momotor.base.checklet.log_helper.safe_repr_iterable(i)¶
Return a safe representation of an iterable suitable for logging
- mtrchk.org.momotor.base.checklet.log_helper.safe_repr_mapping(m)¶
Return a safe representation of a mapping suitable for logging
- mtrchk.org.momotor.base.checklet.log_helper.safe_repr_value(v)¶
Return a safe representation of a value suitable for logging
- class mtrchk.org.momotor.base.checklet.meta.CheckletBaseMeta(name, bases, attrs, **kwargs)¶
Metaclass for all option containers
- class mtrchk.org.momotor.base.checklet.meta.CheckletOptions(options, options_by_name, options_source, description=None, domain=None, location=None)¶
-
description:
str|None= None¶ Description of the checklet (deprecated, use docstring on the Checklet class instead)
-
options:
tuple[OptionDefinition,...]¶ All options
-
options_by_name:
dict[OptionNameDomain,OptionDefinition]¶ The
options, indexed by name and domain
-
options_source:
dict[OptionNameDomain,str]¶ Source checklet of each option. Used for linking options to their canonical location in documentation.
-
description:
- class mtrchk.org.momotor.base.checklet.meta.OptionDefinition¶
A re-export of
momotor.options.OptionDefinition.This is provided for convenience as it is often one of the few classes from the options module that are needed by checklets.
- class mtrchk.org.momotor.base.checklet.meta.OptionNameDomain¶
A re-export of
momotor.options.OptionDomainName.This is provided for convenience as it is often one of the few classes from the options module that are needed by checklets.