Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Settings.ContainerStack.ContainerStack Class Reference
Inheritance diagram for UM.Settings.ContainerStack.ContainerStack:
UM.Settings.Interfaces.ContainerInterface UM.PluginObject.PluginObject

Public Member Functions

None __init__ (self, str stack_id)
 
Tuple[str] __getnewargs__ (self)
 
Dict[str, Any] __getstate__ (self)
 
None __setstate__ (self, Dict[str, Any] state)
 
str getId (self)
 
str getName (self)
 
None setName (self, str name)
 
bool isReadOnly (self)
 
None setReadOnly (self, bool read_only)
 
Dict[str, Any] getMetaData (self)
 
None setMetaData (self, Dict[str, Any] meta_data)
 
Any getMetaDataEntry (self, str entry, Any default=None)
 
None setMetaDataEntry (self, str key, Any value)
 
None removeMetaDataEntry (self, str key)
 
bool isDirty (self)
 
None setDirty (self, bool dirty)
 
Any getProperty (self, str key, str property_name, Optional[PropertyEvaluationContext] context=None)
 
Any getRawProperty (self, str key, str property_name, *, Optional[PropertyEvaluationContext] context=None, bool use_next=True, Optional[ContainerInterface] skip_until_container=None)
 
bool hasProperty (self, str key, str property_name)
 
str serialize (self, Optional[Set[str]] ignored_metadata_keys=None)
 
Optional[str] getConfigurationTypeFromSerialized (cls, str serialized)
 
Optional[int] getVersionFromSerialized (cls, str serialized)
 
str deserialize (self, str serialized, Optional[str] file_name=None)
 
List[Dict[str, Any]] deserializeMetadata (cls, str serialized, str container_id)
 
Set[str] getAllKeys (self)
 
List[ContainerInterfacegetContainers (self)
 
int getContainerIndex (self, ContainerInterface container)
 
ContainerInterface getContainer (self, int index)
 
Optional[ContainerInterfacegetTop (self)
 
Optional[ContainerInterfacegetBottom (self)
 
str getPath (self)
 
None setPath (self, str path)
 
Optional[SettingDefinitiongetSettingDefinition (self, str key)
 
Optional[ContainerInterfacefindContainer (self, Dict[str, Any] criteria=None, type container_type=None, **Any kwargs)
 
None addContainer (self, ContainerInterface container)
 
None insertContainer (self, int index, ContainerInterface container)
 
None replaceContainer (self, int index, ContainerInterface container, bool postpone_emit=False)
 
None removeContainer (self, int index=0)
 
Optional["ContainerStack"] getNextStack (self)
 
None setNextStack (self, "ContainerStack" stack, bool connect_signals=True)
 
None sendPostponedEmits (self)
 
bool hasErrors (self)
 
List[str] getErrorKeys (self)
 
str __str__ (self)
 
str __repr__ (self)
 
- Public Member Functions inherited from UM.Settings.Interfaces.ContainerInterface
 __init__ (self, *args, **kwargs)
 
None setProperty (self, str key, str property_name, Any property_value, "ContainerInterface" container=None, bool set_from_cache=False)
 
int getLoadingPriority (cls)
 
- Public Member Functions inherited from UM.PluginObject.PluginObject
None __init__ (self, *args, **kwags)
 
None setPluginId (self, str plugin_id)
 
str getPluginId (self)
 
None setVersion (self, str version)
 
str getVersion (self)
 

Static Public Attributes

int Version = 6
 
 id = pyqtProperty(str, fget = getId, constant = True)
 
 nameChanged = pyqtSignal()
 
 name = pyqtProperty(str, fget = getName, fset = setName, notify = nameChanged)
 
 readOnlyChanged = pyqtSignal()
 
 readOnly = pyqtProperty(bool, fget = isReadOnly, fset = setReadOnly, notify = readOnlyChanged)
 
 metaData = pyqtProperty("QVariantMap", fget = getMetaData, fset = setMetaData, notify = metaDataChanged)
 
 containersChanged = Signal()
 
 propertiesChanged = Signal(Signal.Queued)
 
- Static Public Attributes inherited from UM.Settings.Interfaces.ContainerInterface
 propertyChanged = None
 
 metaDataChanged = None
 

Protected Member Functions

configparser.ConfigParser _readAndValidateSerialized (cls, str serialized)
 
None _collectPropertyChanges (self, str key, str property_name)
 
None _emitCollectedPropertyChanges (self)
 
- Protected Member Functions inherited from UM.Settings.Interfaces.ContainerInterface
bool _trustHook (self, Optional[str] file_name)
 
str _updateSerialized (cls, str serialized, Optional[str] file_name=None)
 

Protected Attributes

list _containers = []
 
 _next_stack = None
 
bool _read_only = False
 
bool _dirty = False
 
str _path = ""
 
list _postponed_emits = []
 
dict _property_changes = {}
 
bool _emit_property_changed_queued = False
 
 _collectPropertyChanges = _containerRegistry.findContainers(id = container_id)
 
 _emitCollectedPropertyChanges = set()
 
- Protected Attributes inherited from UM.PluginObject.PluginObject
 _plugin_id = None
 
 _version = None
 
dict _metadata = {}
 
 _name = None
 

Detailed Description

A stack of setting containers to handle setting value retrieval.

Constructor & Destructor Documentation

◆ __init__()

None UM.Settings.ContainerStack.ContainerStack.__init__ ( self,
str stack_id )
Constructor

:param stack_id: A unique, machine readable/writable ID.

Member Function Documentation

◆ __getnewargs__()

Tuple[str] UM.Settings.ContainerStack.ContainerStack.__getnewargs__ ( self)
For pickle support

◆ __getstate__()

Dict[str, Any] UM.Settings.ContainerStack.ContainerStack.__getstate__ ( self)
For pickle support

◆ __setstate__()

None UM.Settings.ContainerStack.ContainerStack.__setstate__ ( self,
Dict[str, Any] state )
For pickle support

◆ _readAndValidateSerialized()

configparser.ConfigParser UM.Settings.ContainerStack.ContainerStack._readAndValidateSerialized ( cls,
str serialized )
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.

◆ addContainer()

None UM.Settings.ContainerStack.ContainerStack.addContainer ( self,
ContainerInterface container )
Add a container to the top of the stack.

:param container: The container to add to the stack.

◆ deserialize()

str UM.Settings.ContainerStack.ContainerStack.deserialize ( self,
str serialized,
Optional[str] file_name = None )
:copydoc ContainerInterface::deserialize

Reimplemented from ContainerInterface

TODO: Expand documentation here, include the fact that this should _not_ include all containers

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ deserializeMetadata()

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.

:param serialized: A CFG document, serialised as a string.
:param container_id: The ID of the container that we're getting the
metadata of, as obtained from the file name.
:return: A dictionary of metadata that was in the CFG document as a
singleton list. If anything went wrong, this returns an empty list
instead.

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ findContainer()

Optional[ContainerInterface] UM.Settings.ContainerStack.ContainerStack.findContainer ( self,
Dict[str, Any] criteria = None,
type container_type = None,
**Any kwargs )
Find a container matching certain criteria.

:param criteria: 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.
:param container_type: An optional type of container to filter on.
:return: The first container that matches the filter criteria or None if not found.

◆ getAllKeys()

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.

:return: A set of all setting keys in this container stack.

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getBottom()

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.

:return: The container at the bottom of the stack, or None if no containers have been added.

◆ getConfigurationTypeFromSerialized()

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.

◆ getContainer()

ContainerInterface UM.Settings.ContainerStack.ContainerStack.getContainer ( self,
int index )
Get a container by index.

:param index: The index of the container to get.

:return: The container at the specified index.

:exception IndexError: Raised when the specified index is out of bounds.

◆ getContainers()

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.
:return: A list of all containers in this stack.

◆ getErrorKeys()

List[str] UM.Settings.ContainerStack.ContainerStack.getErrorKeys ( self)
Get all the keys that are in an error state in this stack

◆ getId()

str UM.Settings.ContainerStack.ContainerStack.getId ( self)
:copydoc ContainerInterface::getId

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getMetaData()

Dict[str, Any] UM.Settings.ContainerStack.ContainerStack.getMetaData ( self)
:copydoc ContainerInterface::getMetaData

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getMetaDataEntry()

Any UM.Settings.ContainerStack.ContainerStack.getMetaDataEntry ( self,
str entry,
Any default = None )
:copydoc ContainerInterface::getMetaDataEntry

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getName()

str UM.Settings.ContainerStack.ContainerStack.getName ( self)
:copydoc ContainerInterface::getName

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getNextStack()

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.

:return: :type{ContainerStack} The next stack or None if not set.

◆ getPath()

str UM.Settings.ContainerStack.ContainerStack.getPath ( self)
:copydoc ContainerInterface::getPath.

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getProperty()

Any UM.Settings.ContainerStack.ContainerStack.getProperty ( self,
str key,
str property_name,
Optional[PropertyEvaluationContext] context = None )
:copydoc ContainerInterface::getProperty

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.

◆ getRawProperty()

Any UM.Settings.ContainerStack.ContainerStack.getRawProperty ( self,
str key,
str property_name,
* ,
Optional[PropertyEvaluationContext] context = None,
bool use_next = True,
Optional[ContainerInterface] 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.

:param key: The key to get the property value of.
:param property_name: The name of the property to get the value of.
:param use_next: True if the value should be retrieved from the next
stack if not found in this stack. False if not.
:param 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.

:return: The raw property value of the property, or None if not found. Note that
the value might be a SettingFunction instance.

◆ getSettingDefinition()

Optional[SettingDefinition] UM.Settings.ContainerStack.ContainerStack.getSettingDefinition ( self,
str key )
Get the SettingDefinition object for a specified key

◆ getTop()

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.

:return: The container at the top of the stack, or None if no containers have been added.

◆ getVersionFromSerialized()

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.

◆ hasErrors()

bool UM.Settings.ContainerStack.ContainerStack.hasErrors ( self)
Check if the container stack has errors

◆ hasProperty()

bool UM.Settings.ContainerStack.ContainerStack.hasProperty ( self,
str key,
str property_name )
:copydoc ContainerInterface::hasProperty

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.

◆ insertContainer()

None UM.Settings.ContainerStack.ContainerStack.insertContainer ( self,
int index,
ContainerInterface container )
Insert a container into the stack.

:param index: The index of to insert the container at.
A negative index counts from the bottom
:param container: The container to add to the stack.

◆ isDirty()

bool UM.Settings.ContainerStack.ContainerStack.isDirty ( self)

◆ isReadOnly()

bool UM.Settings.ContainerStack.ContainerStack.isReadOnly ( self)
:copydoc ContainerInterface::isReadOnly

Reimplemented from ContainerInterface

◆ removeContainer()

None UM.Settings.ContainerStack.ContainerStack.removeContainer ( self,
int index = 0 )
Remove a container from the stack.

:param index: :type{int} The index of the container to remove.

:exception IndexError: Raised when the specified index is out of bounds.

◆ replaceContainer()

None UM.Settings.ContainerStack.ContainerStack.replaceContainer ( self,
int index,
ContainerInterface container,
bool postpone_emit = False )
Replace a container in the stack.

:param index: :type{int} The index of the container to replace.
:param container: The container to replace the existing entry with.
:param postpone_emit:  During stack manipulation you may want to emit later.

:exception IndexError: Raised when the specified index is out of bounds.
:exception Exception: when trying to replace container ContainerStack.

◆ sendPostponedEmits()

None 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.

◆ serialize()

str UM.Settings.ContainerStack.ContainerStack.serialize ( self,
Optional[Set[str]] ignored_metadata_keys = None )
:copydoc ContainerInterface::serialize

Reimplemented from ContainerInterface

TODO: Expand documentation here, include the fact that this should _not_ include all containers

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ setDirty()

None UM.Settings.ContainerStack.ContainerStack.setDirty ( self,
bool dirty )

◆ setMetaData()

None UM.Settings.ContainerStack.ContainerStack.setMetaData ( self,
Dict[str, Any] meta_data )
Set the complete set of metadata

Reimplemented from UM.PluginObject.PluginObject.

◆ setName()

None UM.Settings.ContainerStack.ContainerStack.setName ( self,
str name )
Set the name of this stack.

:param name: The new name of the stack.

◆ setNextStack()

None UM.Settings.ContainerStack.ContainerStack.setNextStack ( self,
"ContainerStack" stack,
bool connect_signals = True )
Set the next stack

:param stack: :type{ContainerStack} The next stack to set. Can be None.
Raises Exception when trying to set itself as next stack (to prevent infinite loops)
:sa getNextStack

◆ setPath()

None UM.Settings.ContainerStack.ContainerStack.setPath ( self,
str path )
:copydoc ContainerInterface::setPath

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.


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