Uranium
Application Framework
|
A stack of setting containers to handle setting value retrieval. More...
Public Member Functions | |
__init__ (self, str stack_id, *args, **kwargs) | |
Constructor. | |
__getnewargs__ (self) | |
For pickle support. | |
__getstate__ (self) | |
For pickle support. | |
__setstate__ (self, state) | |
For pickle support. | |
str | getId (self) |
str | getName (self) |
None | setName (self, str name) |
Set the name of this stack. | |
bool | isReadOnly (self) |
setReadOnly (self, read_only) | |
getMetaData (self) | |
setMetaData (self, meta_data) | |
Set the complete set of metadata. | |
getMetaDataEntry (self, str entry, default=None) | |
addMetaDataEntry (self, str key, value) | |
setMetaDataEntry (self, key, value) | |
removeMetaDataEntry (self, key) | |
bool | isDirty (self) |
None | setDirty (self, bool dirty) |
getProperty (self, str key, str property_name, Optional[PropertyEvaluationContext] context=None) | |
getRawProperty (self, key, property_name, *Optional[PropertyEvaluationContext] context=None, use_next=True, skip_until_container=None) | |
Retrieve a property of a setting by key and property name. | |
bool | hasProperty (self, str key, str property_name) |
serialize (self, Optional[set] ignored_metadata_keys=None) | |
Optional[str] | getConfigurationTypeFromSerialized (cls, str serialized) |
Gets the configuration type of the given serialized data. | |
Optional[int] | getVersionFromSerialized (cls, str serialized) |
Gets the version of the given serialized data. | |
str | deserialize (self, serialized, file_name=None) |
List[Dict[str, Any]] | deserializeMetadata (cls, str serialized, str container_id) |
Gets the metadata of a container stack from a serialised format. | |
Set[str] | getAllKeys (self) |
Get all keys known to this container stack. | |
List[ContainerInterface] | getContainers (self) |
Get a list of all containers in this stack. | |
int | getContainerIndex (self, ContainerInterface container) |
ContainerInterface | getContainer (self, int index) |
Get a container by index. | |
Optional[ContainerInterface] | getTop (self) |
Get the container at the top of the stack. | |
Optional[ContainerInterface] | getBottom (self) |
Get the container at the bottom of the stack. | |
str | getPath (self) |
setPath (self, str path) | |
getSettingDefinition (self, str key) | |
Get the SettingDefinition object for a specified key. | |
Optional[ContainerInterface] | findContainer (self, criteria=None, container_type=None, **kwargs) |
Find a container matching certain criteria. | |
addContainer (self, container) | |
Add a container to the top of the stack. | |
insertContainer (self, index, container) | |
Insert a container into the stack. | |
replaceContainer (self, int index, ContainerInterface container, postpone_emit=False) | |
Replace a container in the stack. | |
removeContainer (self, int index=0) | |
Remove a container from the stack. | |
Optional["ContainerStack"] | getNextStack (self) |
Get the next stack. | |
setNextStack (self, "ContainerStack" stack, bool connect_signals=True) | |
Set the next stack. | |
sendPostponedEmits (self) | |
Send postponed emits These emits are collected from the option postpone_emit. | |
bool | hasErrors (self) |
Check if the container stack has errors. | |
List[str] | getErrorKeys (self) |
Get all the keys that are in an error state in this stack. | |
![]() | |
str | getId (self) |
Get the ID of the container. | |
str | getName (self) |
Get the human-readable name of this container. | |
Dict[str, Any] | getMetaData (self) |
Get all metadata of this container. | |
Any | getMetaDataEntry (self, str entry, Any default=None) |
Get the value of a single metadata entry. | |
Any | getProperty (self, str key, str property_name, Optional[PropertyEvaluationContext] context=None) |
Get the value of a property of the container item. | |
bool | hasProperty (self, str key, str property_name) |
Get whether the container item has a specific property. | |
str | serialize (self, Optional[set] ignored_metadata_keys=None) |
Serialize this container to a string. | |
str | deserialize (self, str serialized, Optional[str] file_name=None) |
Deserialize the container from a string representation. | |
List[Dict[str, Any]] | deserializeMetadata (cls, str serialized, str container_id) |
Deserialize just the metadata from a string representation. | |
int | getLoadingPriority (cls) |
Optional[str] | getConfigurationTypeFromSerialized (cls, str serialized) |
Gets the configuration type of the given serialized data. | |
Optional[int] | getVersionFromSerialized (cls, str serialized) |
Gets the version of the given serialized data. | |
str | getPath (self) |
Get the path used to create this InstanceContainer. | |
None | setPath (self, str path) |
Set the path used to create this InstanceContainer. | |
![]() | |
__init__ (self) | |
getPluginId (self) | |
setPluginId (self, plugin_id) | |
Public Attributes | |
Version | |
Static Public Attributes | |
int | Version = 3 |
id = pyqtProperty(str, fget = getId, constant = True) | |
nameChanged = pyqtSignal() | |
Emitted whenever the name of this stack changes. | |
name = pyqtProperty(str, fget = getName, fset = setName, notify = nameChanged) | |
readOnlyChanged = pyqtSignal() | |
readOnly = pyqtProperty(bool, fget = isReadOnly, fset = setReadOnly, notify = readOnlyChanged) | |
metaDataChanged = pyqtSignal(QObject) | |
metaData = pyqtProperty("QVariantMap", fget = getMetaData, fset = setMetaData, notify = metaDataChanged) | |
containersChanged = Signal() | |
propertyChanged = Signal(Signal.Queued) | |
propertiesChanged = Signal(Signal.Queued) | |
![]() | |
propertyChanged = None | |
metaDataChanged = None | |
Protected Member Functions | |
configparser.ConfigParser | _readAndValidateSerialized (cls, str serialized) |
Deserializes the given data and checks if the required fields are present. | |
_collectPropertyChanges (self, str key, str property_name) | |
_emitCollectedPropertyChanges (self) | |
![]() | |
str | _updateSerialized (cls, str serialized, Optional[str] file_name=None) |
Updates the given serialized data to the latest version. | |
Protected Attributes | |
_metadata | |
_containers | |
_next_stack | |
_read_only | |
_dirty | |
_path | |
_postponed_emits | |
_property_changes | |
_emit_property_changed_queued | |
_meta_data | |
_collectPropertyChanges | |
_emitCollectedPropertyChanges | |
![]() | |
_plugin_id | |
A stack of setting containers to handle setting value retrieval.
UM.Settings.ContainerStack.ContainerStack.__init__ | ( | self, | |
str | stack_id, | ||
* | args, | ||
** | kwargs | ||
) |
Constructor.
stack_id | string A unique, machine readable/writable ID. |
Reimplemented from UM.PluginObject.PluginObject.
|
protected |
Deserializes the given data and checks if the required fields are present.
The profile upgrading code depends on information such as "configuration_type" and "version", which come from the serialized data. Due to legacy problem, those data may not be available if it comes from an ancient Cura.
UM.Settings.ContainerStack.ContainerStack.addContainer | ( | self, | |
container | |||
) |
Add a container to the top of the stack.
container | The container to add to the stack. |
str UM.Settings.ContainerStack.ContainerStack.deserialize | ( | self, | |
serialized, | |||
file_name = None |
|||
) |
Reimplemented from ContainerInterface
TODO: Expand documentation here, include the fact that this should not include all containers
Reimplemented from UM.Settings.Interfaces.ContainerInterface.
List[Dict[str, Any]] UM.Settings.ContainerStack.ContainerStack.deserializeMetadata | ( | cls, | |
str | serialized, | ||
str | container_id | ||
) |
Gets the metadata of a container stack from a serialised format.
This parses the entire CFG document and only extracts the metadata from it.
serialized | A CFG document, serialised as a string. |
container_id | The ID of the container that we're getting the metadata of, as obtained from the file name. |
Reimplemented from UM.Settings.Interfaces.ContainerInterface.
Optional[ContainerInterface] UM.Settings.ContainerStack.ContainerStack.findContainer | ( | self, | |
criteria = None , |
|||
container_type = None , |
|||
** | kwargs | ||
) |
Find a container matching certain criteria.
filter | dict A dictionary containing key and value pairs that need to match the container. Note that the value of "*" can be used as a wild card. This will ensure that any container that has the specified key in the meta data is found. |
container_type | class An optional type of container to filter on. |
Set[str] UM.Settings.ContainerStack.ContainerStack.getAllKeys | ( | self | ) |
Get all keys known to this container stack.
In combination with getProperty(), you can obtain the current property values of all settings.
Optional[ContainerInterface] UM.Settings.ContainerStack.ContainerStack.getBottom | ( | self | ) |
Get the container at the bottom of the stack.
This is a convenience method that will always return the bottom of the stack.
Optional[str] UM.Settings.ContainerStack.ContainerStack.getConfigurationTypeFromSerialized | ( | cls, | |
str | serialized | ||
) |
Gets the configuration type of the given serialized data.
(used by __updateSerialized())
Reimplemented from UM.Settings.Interfaces.ContainerInterface.
ContainerInterface UM.Settings.ContainerStack.ContainerStack.getContainer | ( | self, | |
int | index | ||
) |
Get a container by index.
index | int The index of the container to get. |
IndexError | Raised when the specified index is out of bounds. |
List[ContainerInterface] UM.Settings.ContainerStack.ContainerStack.getContainers | ( | self | ) |
Get a list of all containers in this stack.
Note that it returns a shallow copy of the container list, as it's only allowed to change the order or entries in this list by the proper functions.
str UM.Settings.ContainerStack.ContainerStack.getId | ( | self | ) |
Reimplemented from ContainerInterface
Reimplemented from UM.Settings.Interfaces.ContainerInterface.
UM.Settings.ContainerStack.ContainerStack.getMetaData | ( | self | ) |
Reimplemented from ContainerInterface
Reimplemented from UM.Settings.Interfaces.ContainerInterface.
UM.Settings.ContainerStack.ContainerStack.getMetaDataEntry | ( | self, | |
str | entry, | ||
default = None |
|||
) |
Reimplemented from ContainerInterface
Reimplemented from UM.Settings.Interfaces.ContainerInterface.
str UM.Settings.ContainerStack.ContainerStack.getName | ( | self | ) |
Reimplemented from ContainerInterface
Reimplemented from UM.Settings.Interfaces.ContainerInterface.
Optional["ContainerStack"] UM.Settings.ContainerStack.ContainerStack.getNextStack | ( | self | ) |
Get the next stack.
The next stack is the stack that is searched for a setting value if the bottom of the stack is reached when searching for a value.
str UM.Settings.ContainerStack.ContainerStack.getPath | ( | self | ) |
Reimplemented from ContainerInterface
Reimplemented from UM.Settings.Interfaces.ContainerInterface.
UM.Settings.ContainerStack.ContainerStack.getProperty | ( | self, | |
str | key, | ||
str | property_name, | ||
Optional[PropertyEvaluationContext] | context = None |
||
) |
Reimplemented from ContainerInterface.
getProperty will start at the top of the stack and try to get the property specified. If that container returns no value, the next container on the stack will be tried and so on until the bottom of the stack is reached. If a next stack is defined for this stack it will then try to get the value from that stack. If no next stack is defined, None will be returned.
Note that if the property value is a function, this method will return the result of evaluating that property with the current stack. If you need the actual function, use getRawProperty()
Reimplemented from UM.Settings.Interfaces.ContainerInterface.
UM.Settings.ContainerStack.ContainerStack.getRawProperty | ( | self, | |
key, | |||
property_name, | |||
*Optional[PropertyEvaluationContext] | context = None , |
||
use_next = True , |
|||
skip_until_container = None |
|||
) |
Retrieve a property of a setting by key and property name.
This method does the same as getProperty() except it does not perform any special handling of the result, instead the raw stored value is returned.
key | The key to get the property value of. |
property_name | The name of the property to get the value of. |
use_next | True if the value should be retrieved from the next stack if not found in this stack. False if not. |
skip_until_container | A container ID to skip to. If set, it will be as if all containers above the specified container are empty. If the container is not in the stack, it'll try to find it in the next stack. |
Optional[ContainerInterface] UM.Settings.ContainerStack.ContainerStack.getTop | ( | self | ) |
Get the container at the top of the stack.
This is a convenience method that will always return the top of the stack.
Optional[int] UM.Settings.ContainerStack.ContainerStack.getVersionFromSerialized | ( | cls, | |
str | serialized | ||
) |
Gets the version of the given serialized data.
(used by __updateSerialized())
Reimplemented from UM.Settings.Interfaces.ContainerInterface.
bool UM.Settings.ContainerStack.ContainerStack.hasProperty | ( | self, | |
str | key, | ||
str | property_name | ||
) |
Reimplemented from ContainerInterface.
hasProperty will check if any of the containers in the stack has the specified property. If it does, it stops and returns True. If it gets to the end of the stack, it returns False.
Reimplemented from UM.Settings.Interfaces.ContainerInterface.
UM.Settings.ContainerStack.ContainerStack.insertContainer | ( | self, | |
index, | |||
container | |||
) |
Insert a container into the stack.
index | int The index of to insert the container at. A negative index counts from the bottom |
container | The container to add to the stack. |
bool UM.Settings.ContainerStack.ContainerStack.isReadOnly | ( | self | ) |
Reimplemented from ContainerInterface
UM.Settings.ContainerStack.ContainerStack.removeContainer | ( | self, | |
int | index = 0 |
||
) |
Remove a container from the stack.
index | int The index of the container to remove. |
IndexError | Raised when the specified index is out of bounds. |
UM.Settings.ContainerStack.ContainerStack.replaceContainer | ( | self, | |
int | index, | ||
ContainerInterface | container, | ||
postpone_emit = False |
|||
) |
Replace a container in the stack.
index | int The index of the container to replace. |
container | The container to replace the existing entry with. |
postpone_emit | During stack manipulation you may want to emit later. |
IndexError | Raised when the specified index is out of bounds. |
Exception | when trying to replace container ContainerStack. |
UM.Settings.ContainerStack.ContainerStack.sendPostponedEmits | ( | self | ) |
Send postponed emits These emits are collected from the option postpone_emit.
Note: the option can be implemented for all functions modifying the stack.
UM.Settings.ContainerStack.ContainerStack.serialize | ( | self, | |
Optional[set] | ignored_metadata_keys = None |
||
) |
Reimplemented from ContainerInterface
TODO: Expand documentation here, include the fact that this should not include all containers
Reimplemented from UM.Settings.Interfaces.ContainerInterface.
None UM.Settings.ContainerStack.ContainerStack.setName | ( | self, | |
str | name | ||
) |
Set the name of this stack.
name | string The new name of the stack. |
UM.Settings.ContainerStack.ContainerStack.setNextStack | ( | self, | |
"ContainerStack" | stack, | ||
bool | connect_signals = True |
||
) |
Set the next stack.
stack | ContainerStack The next stack to set. Can be None. Raises Exception when trying to set itself as next stack (to prevent infinite loops) |
UM.Settings.ContainerStack.ContainerStack.setPath | ( | self, | |
str | path | ||
) |
Reimplemented from ContainerInterface
Reimplemented from UM.Settings.Interfaces.ContainerInterface.