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

A stack of setting containers to handle setting value retrieval. More...

Inheritance diagram for UM.Settings.ContainerStack.ContainerStack:
UM.Settings.Interfaces.ContainerInterface UM.PluginObject.PluginObject

Public Member Functions

def __init__ (self, str stack_id, *args, **kwargs)
 Constructor. More...
 
def __getnewargs__ (self)
 For pickle support.
 
def __getstate__ (self)
 For pickle support.
 
def __setstate__ (self, state)
 For pickle support.
 
str getId (self)
 Get the ID of the container. More...
 
str getName (self)
 Get the human-readable name of this container. More...
 
None setName (self, str name)
 Set the name of this stack. More...
 
bool isReadOnly (self)
 
def setReadOnly (self, read_only)
 
def getMetaData (self)
 Get all metadata of this container. More...
 
def setMetaData (self, meta_data)
 Set the complete set of metadata.
 
def getMetaDataEntry (self, str entry, default=None)
 Get the value of a single metadata entry. More...
 
def addMetaDataEntry (self, str key, value)
 
def setMetaDataEntry (self, key, value)
 
def removeMetaDataEntry (self, key)
 
bool isDirty (self)
 
None setDirty (self, bool dirty)
 
def getProperty (self, str key, str property_name, Optional[PropertyEvaluationContext] context=None)
 Get the value of a property of the container item. More...
 
def 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. More...
 
bool hasProperty (self, str key, str property_name)
 Get whether the container item has a specific property. More...
 
def serialize (self, Optional[set] ignored_metadata_keys=None)
 Serialize this container to a string. More...
 
Optional[str] getConfigurationTypeFromSerialized (cls, str serialized)
 Gets the configuration type of the given serialized data. More...
 
Optional[int] getVersionFromSerialized (cls, str serialized)
 Gets the version of the given serialized data. More...
 
str deserialize (self, serialized, file_name=None)
 Deserialize the container from a string representation. More...
 
List[Dict[str, Any]] deserializeMetadata (cls, str serialized, str container_id)
 Gets the metadata of a container stack from a serialised format. More...
 
Set[str] getAllKeys (self)
 Get all keys known to this container stack. More...
 
List[ContainerInterfacegetContainers (self)
 Get a list of all containers in this stack. More...
 
int getContainerIndex (self, ContainerInterface container)
 
ContainerInterface getContainer (self, int index)
 Get a container by index. More...
 
Optional[ContainerInterfacegetTop (self)
 Get the container at the top of the stack. More...
 
Optional[ContainerInterfacegetBottom (self)
 Get the container at the bottom of the stack. More...
 
str getPath (self)
 
def setPath (self, str path)
 Set the path used to create this InstanceContainer. More...
 
def getSettingDefinition (self, str key)
 Get the SettingDefinition object for a specified key.
 
Optional[ContainerInterfacefindContainer (self, criteria=None, container_type=None, **kwargs)
 Find a container matching certain criteria. More...
 
def addContainer (self, container)
 Add a container to the top of the stack. More...
 
def insertContainer (self, index, container)
 Insert a container into the stack. More...
 
def replaceContainer (self, int index, ContainerInterface container, postpone_emit=False)
 Replace a container in the stack. More...
 
def removeContainer (self, int index=0)
 Remove a container from the stack. More...
 
Optional["ContainerStack"] getNextStack (self)
 Get the next stack. More...
 
def setNextStack (self, "ContainerStack" stack, bool connect_signals=True)
 Set the next stack. More...
 
def sendPostponedEmits (self)
 Send postponed emits These emits are collected from the option postpone_emit. More...
 
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.
 
- Public Member Functions inherited from UM.Settings.Interfaces.ContainerInterface
Any getMetaDataEntry (self, str entry, Any default=None)
 Get the value of a single metadata entry. More...
 
str deserialize (self, str serialized, Optional[str] file_name=None)
 Deserialize the container from a string representation. More...
 
int getLoadingPriority (cls)
 
- Public Member Functions inherited from UM.PluginObject.PluginObject
def __init__ (self)
 
def getPluginId (self)
 
def setPluginId (self, plugin_id)
 

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)
 
- Static Public Attributes inherited from UM.Settings.Interfaces.ContainerInterface
 propertyChanged = None
 
 metaDataChanged = None
 

Detailed Description

A stack of setting containers to handle setting value retrieval.

Constructor & Destructor Documentation

◆ __init__()

def UM.Settings.ContainerStack.ContainerStack.__init__ (   self,
str  stack_id,
args,
**  kwargs 
)

Constructor.

Parameters
stack_idstring A unique, machine readable/writable ID.

Member Function Documentation

◆ addContainer()

def UM.Settings.ContainerStack.ContainerStack.addContainer (   self,
  container 
)

Add a container to the top of the stack.

Parameters
containerThe container to add to the stack.

◆ deserialize()

str UM.Settings.ContainerStack.ContainerStack.deserialize (   self,
  serialized,
  file_name = None 
)

Deserialize the container from a string representation.

This should replace the contents of this container with those in the serialized representation.

Parameters
serializedA serialized string containing a container that should be deserialized.

Reimplemented from ContainerInterface

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

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

Parameters
serializedA CFG document, serialised as a string.
container_idThe ID of the container that we're getting the metadata of, as obtained from the file name.
Returns
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,
  criteria = None,
  container_type = None,
**  kwargs 
)

Find a container matching certain criteria.

Parameters
filterdict 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_typeclass An optional type of container to filter on.
Returns
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.

Returns
A set of all setting keys in this container stack.

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

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

Parameters
indexint The index of the container to get.
Returns
The container at the specified index.
Exceptions
IndexErrorRaised 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.

Returns
list A list of all containers in this stack.

◆ getId()

str UM.Settings.ContainerStack.ContainerStack.getId (   self)

Get the ID of the container.

The ID should be unique, machine readable and machine writable. It is intended to be used for example when referencing the container in configuration files or when writing a file to disk.

Returns
string The unique ID of this container.

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getMetaData()

def UM.Settings.ContainerStack.ContainerStack.getMetaData (   self)

Get all metadata of this container.

This returns a dictionary containing all the metadata for this container. How this metadata is used depends on the application.

Returns
dict The metadata for this container.

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getMetaDataEntry()

def UM.Settings.ContainerStack.ContainerStack.getMetaDataEntry (   self,
str  entry,
  default = None 
)

Get the value of a single metadata entry.

Parameters
entrystring The key of the metadata to retrieve.
defaultThe default value to return if the entry cannot be found.
Returns
The value of the metadata corresponding to name, or default when the entry could not be found.

Reimplemented from ContainerInterface

◆ getName()

str UM.Settings.ContainerStack.ContainerStack.getName (   self)

Get the human-readable name of this container.

This should return a human-readable name for the container, that can be used in the interface.

Returns
string The name of this container.

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.

Returns
ContainerStack The next stack or None if not set.

◆ getPath()

str UM.Settings.ContainerStack.ContainerStack.getPath (   self)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getProperty()

def UM.Settings.ContainerStack.ContainerStack.getProperty (   self,
str  key,
str  property_name,
Optional[PropertyEvaluationContext]   context = None 
)

Get the value of a property of the container item.

Parameters
keystring The key of the item to retrieve a property from.
namestring The name of the property to retrieve.
Returns
The specified property value of the container item corresponding to key, or None if not found.

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()

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

Parameters
keyThe key to get the property value of.
property_nameThe name of the property to get the value of.
use_nextTrue if the value should be retrieved from the next stack if not found in this stack. False if not.
skip_until_containerA 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.
Returns
The raw property value of the property, or None if not found. Note that the value might be a SettingFunction instance.

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

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

◆ hasProperty()

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

Get whether the container item has a specific property.

Parameters
keyThe key of the item to check the property from.
nameThe name of the property to check for.
Returns
True if the specified item has the property, or False if it doesn't.

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()

def UM.Settings.ContainerStack.ContainerStack.insertContainer (   self,
  index,
  container 
)

Insert a container into the stack.

Parameters
indexint The index of to insert the container at. A negative index counts from the bottom
containerThe container to add to the stack.

◆ isReadOnly()

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

Reimplemented from ContainerInterface

◆ removeContainer()

def UM.Settings.ContainerStack.ContainerStack.removeContainer (   self,
int   index = 0 
)

Remove a container from the stack.

Parameters
indexint The index of the container to remove.
Exceptions
IndexErrorRaised when the specified index is out of bounds.

◆ replaceContainer()

def UM.Settings.ContainerStack.ContainerStack.replaceContainer (   self,
int  index,
ContainerInterface  container,
  postpone_emit = False 
)

Replace a container in the stack.

Parameters
indexint The index of the container to replace.
containerThe container to replace the existing entry with.
postpone_emitDuring stack manipulation you may want to emit later.
Exceptions
IndexErrorRaised when the specified index is out of bounds.
Exceptionwhen trying to replace container ContainerStack.

◆ sendPostponedEmits()

def 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()

def UM.Settings.ContainerStack.ContainerStack.serialize (   self,
Optional[set]   ignored_metadata_keys = None 
)

Serialize this container to a string.

The serialized representation of the container can be used to write the container to disk or send it over the network.

Parameters
ignored_metadata_keysA set of keys that should be ignored when it serializes the metadata.
Returns
string A string representation of this container.

Reimplemented from ContainerInterface

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

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ setName()

None UM.Settings.ContainerStack.ContainerStack.setName (   self,
str  name 
)

Set the name of this stack.

Parameters
namestring The new name of the stack.

◆ setNextStack()

def UM.Settings.ContainerStack.ContainerStack.setNextStack (   self,
"ContainerStack"  stack,
bool   connect_signals = True 
)

Set the next stack.

Parameters
stackContainerStack The next stack to set. Can be None. Raises Exception when trying to set itself as next stack (to prevent infinite loops)
See also
getNextStack

◆ setPath()

def UM.Settings.ContainerStack.ContainerStack.setPath (   self,
str  path 
)

Set the path used to create this InstanceContainer.

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.


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