muteria.common.mix module

This Module implement some utility mathods used throughout the project. - The function confirm_execution is usefule to request user

confirmation before proceeding the execution of a task that is considered important to verify user certainty in proceeding. An example is the deletion of the data directory…

  • The class ErrorHandler define function that are called to

    terminate the execution gracefully and informativelly upon error.

class muteria.common.mix.EnumAutoName(value)[source]

Bases: Enum

This is a base class that can be used to define enums, Extend this class to generate an enum that will have the methods defined here.

get_field_value()[source]

get the value of the enum field. :Example: >>> class MyEnum(EnumAutoName): … FIELD1 = “abc” … FIELD2 = 3 … >>> my = MyEnum >>> my.FIELD1.get_field_value() ‘abc’

get_str()[source]

get the string representation of the enum field. :Example: >>> class MyEnum(EnumAutoName): … FIELD1 = “abc” … FIELD2 = 3 … >>> my = MyEnum >>> my.FIELD1.get_str() ‘FIELD1’

classmethod has_element_named(e_name)[source]

Check that the string e_name represent the name of a field of the enum. :Example: >>> class MyEnum(EnumAutoName): … FIELD1 = “abc” … FIELD2 = 3 … >>> MyEnum.has_element_named(“FIELD1”) True >>> MyEnum.has_element_named(“xyz”) False

classmethod is_valid(elem)[source]

Check that the object elem is a field of the enum :Example: >>> class MyEnum(EnumAutoName): … FIELD1 = “abc” … FIELD2 = 3 … >>> MyEnum.is_valid(MyEnum.FIELD1) True >>> MyEnum.is_valid(“FIELD1”) False

class muteria.common.mix.ErrorHandler[source]

Bases: object

classmethod assert_true(condition, err_string=None, call_location=None, ask_revert=True)[source]

Call this function with the parameter __file__ as location_called_from

classmethod error_exit(err_string=None, call_location=None, error_code=1, ask_revert=True, from_assert=False)[source]
error_exit_revert_repo_called = False
repos_dir_manager = None
classmethod set_corresponding_repos_manager(repos_dir_manager)[source]
class muteria.common.mix.GlobalConstants[source]

Bases: object

COMMAND_FAILURE = 1
COMMAND_SUCCESS = 0
COMMAND_UNCERTAIN = None
ELEMENT_COVERED_VERDICT = 1
ELEMENT_NOTCOVERED_VERDICT = 0
ELEMENT_UNCERTAIN_VERDICT = None
FAIL_TEST_VERDICT = 1
PASS_TEST_VERDICT = 0
TEST_EXECUTION_ERROR = -1
UNCERTAIN_TEST_VERDICT = None
muteria.common.mix.confirm_execution(question)[source]

Ask user to enter Y or N (case-insensitive).

Returns:

True if the answer is Y.

Return type:

bool