Uranium
Application Framework
UM.Settings.SettingFunction.SettingFunction Class Reference

Encapsulates Python code that provides a simple value calculation function. More...

Inheritance diagram for UM.Settings.SettingFunction.SettingFunction:
UM.Settings.Validator.Validator

Public Member Functions

None __init__ (self, str code)
 Constructor. More...
 
Any __call__ (self, ContainerInterface value_provider, Optional[PropertyEvaluationContext] context=None)
 Call the actual function to calculate the value.
 
bool __eq__ (self, other)
 
bool isValid (self)
 Returns whether the function is ready to be executed. More...
 
FrozenSet[str] getUsedSettingKeys (self)
 Retrieve a set of the keys (strings) of all the settings used in this function. More...
 
str __str__ (self)
 
str __repr__ (self)
 
Dict[str, Any] __getstate__ (self)
 To support Pickle. More...
 
None __setstate__ (self, Dict[str, Any] state)
 
None registerOperator (cls, str name, Callable operator)
 Expose a custom function to the code executed by SettingFunction. More...
 

Detailed Description

Encapsulates Python code that provides a simple value calculation function.

Constructor & Destructor Documentation

◆ __init__()

None UM.Settings.SettingFunction.SettingFunction.__init__ (   self,
str  code 
)

Constructor.

Parameters
codeThe Python code this function should evaluate.

Reimplemented in UM.Settings.Validator.Validator.

Member Function Documentation

◆ __getstate__()

Dict[str, Any] UM.Settings.SettingFunction.SettingFunction.__getstate__ (   self)

To support Pickle.

Pickle does not support the compiled code, so instead remove it from the state. We can re-compile it later on anyway.

◆ getUsedSettingKeys()

FrozenSet[str] UM.Settings.SettingFunction.SettingFunction.getUsedSettingKeys (   self)

Retrieve a set of the keys (strings) of all the settings used in this function.

Returns
A set of the keys (strings) of all the settings used in this functions.

◆ isValid()

bool UM.Settings.SettingFunction.SettingFunction.isValid (   self)

Returns whether the function is ready to be executed.

Returns
True if the function is valid, or False if it's not.

◆ registerOperator()

None UM.Settings.SettingFunction.SettingFunction.registerOperator (   cls,
str  name,
Callable  operator 
)

Expose a custom function to the code executed by SettingFunction.

Parameters
nameWhat identifier to use in the executed code.
operatorA callable that implements the actual logic to execute.

The documentation for this class was generated from the following file: