Muscat.Helpers.LocalVariables module

AddCommonConstants(target: ~Muscat.Helpers.LocalVariables.LocalVariables = <Muscat.Helpers.LocalVariables.LocalVariables object>) None[source]

Add common constant to a LocalVariables instance

variable added :

yotta zetta exa peta tera giga mega kilo hecto deka deci centi milli micro nano pico femto atto zepto yocto pi GradToDegree DegreeToGrad

Parameters:

target (LocalVariables, optional) – An instance of LocalVariables, by default the global LocalVariables of Muscat is used

AddToGlobalDictionary(name: str, value: Any) None[source]

Add a variable and its value to the global variable space of Muscat

Parameters:
  • name (str) – name of the variable

  • value (Any) – The Value of the variable

ApplyGlobalDictionary(string: str | D) str | D[source]

Modified and return the string provided using the global variable space of Muscat. please read py:class:LocalVariables.Apply for more information, if input is not string then is returned as it (no modification)

Parameters:

string (str) – The user string to be treated

Returns:

The string with the variable values in place of the variable names

Return type:

str

CheckIntegrity(GUI: bool = False) str[source]
class LocalVariables(prePostChars: Tuple[str, str] = ('{', '}'))[source]

Bases: object

Class to store user variables names and values the user can then replace this variable in a string

Apply(string: str | D) str | D[source]

Modified and return the string provided. Search and replace the variable names on the string by their value the search is done using the prePostChars I.e.

.SetVariable(“data”,5) .Apply(“{data}+1”) -> “5+1”

Warning: the values are converted to string to be inserted in the string

Parameters:

string (str) – The user string to be treated

Returns:

The string with the variable values in place of the variable names

Return type:

str

SetVariable(name: str, value: Any) None[source]

Set a internal the value (value) of variable (name)

Parameters:
  • name (str) – name of the variable

  • value (Any) – The Value of the variable

UnsetVariable(name: str) None[source]

Remove a variable for the internal storage

Parameters:

name (str) – name of the variable to be removed

RemoveFromGlobalDictionary(name: str) None[source]

Remove a variable from the global variable space of Muscat

Parameters:

name (str) – name of the variable