![]() |
Terarea
2
The automation project
|
Public Member Functions | |
__init__ (self, int success=0, int error=84, bool debug=False) | |
None | __del__ (self) |
int | create_scope (self, Any scope_name) |
int | add_variable (self, str name, Any variable_data, Type variable_type=str, Any scope="default_scope") |
int | update_variable (self, str name, Any variable_data, Type variable_type=str, Any scope="default_scope") |
int | insert_or_update (self, str name, Any variable_data, Type variable_type=str, Any scope="default_scope") |
bool | has_variable (self, str name, Any scope="default_scope") |
Any | get_variable (self, str name, Any scope="default_scope") |
Dict[str, Any] | get_variables (self, Any scope="default_scope") |
Dict[str, Any] | get_scope (self, Any scope="default_scope") |
Union[int, Type] | get_variable_type (self, str name, Any scope="default_scope") |
int | remove_variable (self, str name, Any scope="default_scope") |
int | clear_variables (self, Any scope="default_scope") |
int | clear_scopes (self) |
int | clear_scope_contents (self) |
int | remove_scope (self, Any scope) |
Any | sanitize_for_json (self, Any data_or_scope, bool use_scope=False) |
Data Fields | |
int | success = success |
int | error = error |
bool | debug = debug |
dict | variables = {} |
Disp | disp |
str | variables = f"Scope {scope} not found." |
_summary_
Definition at line 24 of file variables.py.
src.lib.actions.variables.Variables.__init__ | ( | self, | |
int | success = 0, | ||
int | error = 84, | ||
bool | debug = False ) |
_summary_ Class in charge of storing and restoring variables. Args: success (int, optional): _description_. Defaults to 0. error (int, optional): _description_. Defaults to 84. debug (bool, optional): _description_. Defaults to False.
Definition at line 28 of file variables.py.
None src.lib.actions.variables.Variables.__del__ | ( | self | ) |
_summary_ Destructor for the class.
Definition at line 53 of file variables.py.
int src.lib.actions.variables.Variables.add_variable | ( | self, | |
str | name, | ||
Any | variable_data, | ||
Type | variable_type = str, | ||
Any | scope = "default_scope" ) |
_summary_ Add a variable to the current action. Args: name (str): _description_: The name of the variable variable_data (Any): _description_: The data of the given variable variable_type (Type): _description_: The type of the data scope (str, optional): _description_: The scope of the variable, defaults to "default_scope" Raises: TypeError: _description_: If the type of the variable is incorrect. Returns: int: _description_: Returns self.success if it succeeds, self.error otherwise.
Definition at line 82 of file variables.py.
int src.lib.actions.variables.Variables.clear_scope_contents | ( | self | ) |
_summary_ Clear all the scopes content from the current action. Returns: int: _description_
Definition at line 401 of file variables.py.
int src.lib.actions.variables.Variables.clear_scopes | ( | self | ) |
_summary_ Clear all the scopes from the current action. Returns: int: _description_
Definition at line 388 of file variables.py.
int src.lib.actions.variables.Variables.clear_variables | ( | self, | |
Any | scope = "default_scope" ) |
_summary_ Clear all the variables from the current action. Args: scope (str, optional): _description_: The scope in which to clear the variables. Enter '*' to clear the content of all the scopes. Defaults to "default_scope". Returns: int: _description_: Returns self.success if it succeeds, self.error otherwise.
Definition at line 358 of file variables.py.
int src.lib.actions.variables.Variables.create_scope | ( | self, | |
Any | scope_name ) |
_summary_ Create a new scope. Args: scope_name (Any): _description_: The name of the scope. Returns: int: _description_: Returns self.success if it succeeds, self.error otherwise.
Definition at line 62 of file variables.py.
Dict[str, Any] src.lib.actions.variables.Variables.get_scope | ( | self, | |
Any | scope = "default_scope" ) |
_summary_ The function in charge of returning the content of a scope. This function is just there for program logic. This is function behaves the exact same way as the get_variables function. Args: scope (str, optional): _description_: The scope in which to get the variables. User '*' to return all the vairables from all the scopes. Defaults to "default_scope". Raises: ScopeError: _description_: If the scope is not found. Returns: Dict[str, Any]: _description_: Returns all the variables.
Definition at line 280 of file variables.py.
Any src.lib.actions.variables.Variables.get_variable | ( | self, | |
str | name, | ||
Any | scope = "default_scope" ) |
_summary_ Get the variable from the current action. Args: name (str): _description_: The name of the variable scope (str, optional): _description_: The scope in which to get the variable. Defaults to "default_scope". Raises: ScopeError: _description_: If the scope is not found. ValueError: _description_: If the variable does not exist. Returns: Any: _description_: Returns the variable if it exists, self.error otherwise.
Definition at line 230 of file variables.py.
Union[int, Type] src.lib.actions.variables.Variables.get_variable_type | ( | self, | |
str | name, | ||
Any | scope = "default_scope" ) |
_summary_ Get the type of the variable from the current action. Args: name (str): _description_: The name of the variable scope (str, optional): _description_: The scope in which to get the variable. Defaults to "default_scope". Raises: ScopeError: _description_: If the scope is not ValueError: _description_: If the variable does not exist. Returns: Type: _description_: Returns the type of the variable if it exists, self.error otherwise.
Definition at line 297 of file variables.py.
Dict[str, Any] src.lib.actions.variables.Variables.get_variables | ( | self, | |
Any | scope = "default_scope" ) |
_summary_ Get all the variables from the current action. Args: scope (str, optional): _description_: The scope in which to get the variables. User '*' to return all the vairables from all the scopes. Defaults to "default_scope". Raises: ScopeError: _description_: If the scope is not found. Returns: Dict[str, Any]: _description_: Returns all the variables.
Definition at line 257 of file variables.py.
bool src.lib.actions.variables.Variables.has_variable | ( | self, | |
str | name, | ||
Any | scope = "default_scope" ) |
_summary_ Check if the variable exists in the current action. Args: name (str): _description_: The name of the variable scope (str, optional): _description_: The scope in which we wish to search for the variable. Enter '*' to search all the variable scopes. Defaults to "default_scope" Raises: ScopeError: _description_: If the scope is not found. Returns: bool: _description_: Returns True if the variable exists, False otherwise.
Definition at line 193 of file variables.py.
int src.lib.actions.variables.Variables.insert_or_update | ( | self, | |
str | name, | ||
Any | variable_data, | ||
Type | variable_type = str, | ||
Any | scope = "default_scope" ) |
_summary_ Insert or update the variable from the current action. Args: name (str): _description_: The name of the variable variable_data (Any): _description_: The data of the given variable variable_type (Type): _description_: The type of the data scope (str, optional): _description_: The scope in which the data is stored. Defaults to "default_scope" Raises: ValueError: _description_: If the variable does not exist. TypeError: _description_: If the type of the variable is incorrect ScopeError: _description_: If the scope is not found. VariableNotFoundError: _description_: If the variable is not found. Returns: int: _description_: Returns self.success if it succeeds, self.error otherwise.
Definition at line 158 of file variables.py.
int src.lib.actions.variables.Variables.remove_scope | ( | self, | |
Any | scope ) |
_summary_ Remove the scope from the current action. Args: scope (str): _description_: The scope to remove. Raises: ScopeError: _description_: If the scope is not found. Returns: int: _description_: Returns self.success if it succeeds, self.error otherwise.
Definition at line 416 of file variables.py.
int src.lib.actions.variables.Variables.remove_variable | ( | self, | |
str | name, | ||
Any | scope = "default_scope" ) |
_summary_ Remove the variable from the current action. Args: name (str): _description_: The name of the variable scope (str, optional): _description_: The scope in which the variable is stored. Defaults to "default_scope". Raises: ScopeError: _description_: If the scope is not found. VariableNotFoundError: _description_: If the variable is not found. Returns: int: _description_: Returns self.success if it succeeds, self.error otherwise.
Definition at line 324 of file variables.py.
Any src.lib.actions.variables.Variables.sanitize_for_json | ( | self, | |
Any | data_or_scope, | ||
bool | use_scope = False ) |
_summary_ Sanitize the data for json serialization. Args: data (Any): _description_: The data to sanitize. use_scope (bool, optional): _description_: Specify if the data to process is to be queried in the variable scopes. Default: False Raises: ScopeError: _description_: If the scope is not found. Returns: Any: _description_: The sanitized data.
Definition at line 439 of file variables.py.
int src.lib.actions.variables.Variables.update_variable | ( | self, | |
str | name, | ||
Any | variable_data, | ||
Type | variable_type = str, | ||
Any | scope = "default_scope" ) |
_summary_ Update the variable from the current action. Args: name (str): _description_: The name of the variable variable_data (Any): _description_: The data of the given variable variable_type (Type): _description_: The type of the data scope (str, optional): _description_: The scope in which the data is stored. Defaults to "default_scope" Raises: ScopeError: _description_: If the scope is not found. VariableNotFoundError: _description_: If the variable is not found. TypeError: _description_: If the type of the variable is incorrect Returns: int: _description_: Returns self.success if it succeeds, self.error otherwise.
Definition at line 120 of file variables.py.
bool src.lib.actions.variables.Variables.debug = debug |
Definition at line 40 of file variables.py.
Disp src.lib.actions.variables.Variables.disp |
Definition at line 44 of file variables.py.
int src.lib.actions.variables.Variables.error = error |
Definition at line 39 of file variables.py.
int src.lib.actions.variables.Variables.success = success |
Definition at line 38 of file variables.py.
str src.lib.actions.variables.Variables.variables = {} |
Definition at line 42 of file variables.py.
str src.lib.actions.variables.Variables.variables = f"Scope {scope} not found." |
Definition at line 139 of file variables.py.