Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Settings.ContainerRegistry.ContainerRegistry Class Reference
Inheritance diagram for UM.Settings.ContainerRegistry.ContainerRegistry:
UM.Settings.Interfaces.ContainerRegistryInterface

Public Member Functions

None __init__ (self, "QtApplication" application)
 
None addResourceType (self, int resource_type, str container_type)
 
Dict[str, int] getResourceTypes (self)
 
"ContainerProvider" getDefaultSaveProvider (self)
 
None addWrongContainerId (self, str wrong_container_id)
 
None addProvider (self, ContainerProvider provider)
 
None addAdditionalSettingDefinitionsAppender (self, AdditionalSettingDefinitionsAppender appender)
 
List[DefinitionContainerInterface] findDefinitionContainers (self, **Any kwargs)
 
List[Dict[str, Any]] findDefinitionContainersMetadata (self, **Any kwargs)
 
List[InstanceContainerfindInstanceContainers (self, **Any kwargs)
 
List[metadata_type] findInstanceContainersMetadata (self, **Any kwargs)
 
List[ContainerStackfindContainerStacks (self, **Any kwargs)
 
List[metadata_type] findContainerStacksMetadata (self, **Any kwargs)
 
List[ContainerInterfacefindContainers (self, *bool ignore_case=False, **Any kwargs)
 
List[metadata_type] findContainersMetadata (self, *bool ignore_case=False, **Any kwargs)
 
List[ContainerInterfacefindDirtyContainers (self, *bool ignore_case=False, **Any kwargs)
 
InstanceContainer getEmptyInstanceContainer (self)
 
None setExplicitReadOnly (self, str container_id)
 
bool isExplicitReadOnly (self, str container_id)
 
bool isReadOnly (self, str container_id)
 
Optional[str] getContainerFilePathById (self, str container_id)
 
bool isLoaded (self, str container_id)
 
None loadAllMetadata (self)
 
None load (self)
 
bool addContainer (self, ContainerInterface container)
 
None removeContainer (self, str container_id)
 
None renameContainer (self, str container_id, str new_name, Optional[str] new_id=None)
 
str uniqueName (self, str original)
 
None addContainerType (cls, "PluginObject" container)
 
None addContainerTypeByName (cls, type container_type, str type_name, str mime_type)
 
Optional[MimeTypegetMimeTypeForContainer (cls, type container_type)
 
Optional[Type[ContainerInterface]] getContainerForMimeType (cls, MimeType mime_type)
 
 getContainerTypes (cls)
 
None saveContainer (self, "ContainerInterface" container, Optional["ContainerProvider"] provider=None)
 
None saveDirtyContainers (self)
 
str getLockFilename (self)
 
str getCacheLockFilename (self)
 
LockFile lockFile (self)
 
LockFile lockCache (self)
 
"ContainerRegistry" getInstance (cls, *args, **kwargs)
 
- Public Member Functions inherited from UM.Settings.Interfaces.ContainerRegistryInterface
"Application" getApplication (cls)
 

Public Attributes

 addProvider
 
 addAdditionalSettingDefinitionsAppender
 
 metadata
 
 source_provider
 

Static Public Attributes

 containerAdded = Signal()
 
 containerRemoved = Signal()
 
 containerMetaDataChanged = Signal()
 
 containerLoadComplete = Signal()
 
 allMetadataLoaded = Signal()
 
dict mime_type_map
 

Protected Member Functions

db.Connection _createDatabaseFile (self, str db_path)
 
db.Connection _getDatabaseConnection (self)
 
Optional[str] _getProfileType (self, str container_id, db.Cursor db_cursor)
 
None _recreateCorruptDataBase (self, Optional[db.Cursor] cursor)
 
Optional[float] _getProfileModificationTime (self, str container_id, db.Cursor db_cursor)
 
None _addMetadataToDatabase (self, metadata_type metadata)
 
None _updateMetadataInDatabase (self, metadata_type metadata)
 
metadata_type _getMetadataFromDatabase (self, str container_id, str container_type)
 
None _removeContainerFromDatabase (self, str container_id)
 
None _clearQueryCache (self, *Any args, **Any kwargs)
 
None _clearQueryCacheByContainer (self, ContainerInterface container)
 
None _onContainerMetaDataChanged (self, *ContainerInterface args, **Any kwargs)
 
bool _isMetadataValid (self, Optional[metadata_type] metadata)
 

Protected Attributes

 _application
 
 _emptyInstanceContainer
 
 _providers
 
 _containers
 
 _wrong_container_ids
 
 _resource_types
 
 _clearQueryCache
 
 _explicit_read_only_container_ids
 
 _db_connection
 
 _onContainerMetaDataChanged
 

Detailed Description

Central class to manage all setting providers.

This class aggregates all data from all container providers. If only the
metadata is used, it requests the metadata lazily from the providers. If
more than that is needed, the entire container is requested from the
appropriate providers.

Member Function Documentation

◆ _clearQueryCacheByContainer()

None UM.Settings.ContainerRegistry.ContainerRegistry._clearQueryCacheByContainer ( self,
ContainerInterface container )
protected
Clear the query cache by using container type.
This is a slightly smarter way of clearing the cache. Only queries that are of the same type (or without one)
are cleared.

◆ _isMetadataValid()

bool UM.Settings.ContainerRegistry.ContainerRegistry._isMetadataValid ( self,
Optional[metadata_type] metadata )
protected
Validate a metadata object.

If the metadata is invalid, the container is not allowed to be in the
registry.
:param metadata: A metadata object.
:return: Whether this metadata was valid.

◆ _onContainerMetaDataChanged()

None UM.Settings.ContainerRegistry.ContainerRegistry._onContainerMetaDataChanged ( self,
*ContainerInterface args,
**Any kwargs )
protected
Called when any container's metadata changed.

This function passes it on to the containerMetaDataChanged signal. Sadly
that doesn't work automatically between pyqtSignal and UM.Signal.

◆ _recreateCorruptDataBase()

None UM.Settings.ContainerRegistry.ContainerRegistry._recreateCorruptDataBase ( self,
Optional[db.Cursor] cursor )
protected
Closes the Database, removes the file from cache and recreate all metadata from scratch

◆ addAdditionalSettingDefinitionsAppender()

None UM.Settings.ContainerRegistry.ContainerRegistry.addAdditionalSettingDefinitionsAppender ( self,
AdditionalSettingDefinitionsAppender appender )
Adds a provider for additional setting definitions to append to each definition-container.

◆ addContainerType()

None UM.Settings.ContainerRegistry.ContainerRegistry.addContainerType ( cls,
"PluginObject" container )
Add a container type that will be used to serialize/deserialize containers.

:param container: An instance of the container type to add.

◆ addContainerTypeByName()

None UM.Settings.ContainerRegistry.ContainerRegistry.addContainerTypeByName ( cls,
type container_type,
str type_name,
str mime_type )
Used to associate mime types with object to be created
:param container_type:  ContainerStack or derivative
:param type_name:
:param mime_type:

◆ addProvider()

None UM.Settings.ContainerRegistry.ContainerRegistry.addProvider ( self,
ContainerProvider provider )
Adds a container provider to search through containers in.

◆ addWrongContainerId()

None UM.Settings.ContainerRegistry.ContainerRegistry.addWrongContainerId ( self,
str wrong_container_id )
This method adds the current id to the list of wrong containers that are skipped when looking for a container

◆ findContainers()

List[ContainerInterface] UM.Settings.ContainerRegistry.ContainerRegistry.findContainers ( self,
*bool ignore_case = False,
**Any kwargs )
Find all container objects matching certain criteria.

:param container_type: If provided, return only objects that are
instances or subclasses of container_type.
:param kwargs: A dictionary of keyword arguments containing
keys and values that need to match the metadata of the container. An
asterisk can be used to denote a wildcard.

:return: A list of containers matching the search criteria, or an empty
list if nothing was found.

Reimplemented from UM.Settings.Interfaces.ContainerRegistryInterface.

◆ findContainersMetadata()

List[metadata_type] UM.Settings.ContainerRegistry.ContainerRegistry.findContainersMetadata ( self,
*bool ignore_case = False,
**Any kwargs )
Find the metadata of all container objects matching certain criteria.

:param container_type: If provided, return only objects that are
instances or subclasses of ``container_type``.
:param kwargs: A dictionary of keyword arguments containing keys and
values that need to match the metadata. An asterisk can be used to
denote a wildcard.
:return: A list of metadata dictionaries matching the search criteria, or
an empty list if nothing was found.

◆ findContainerStacks()

List[ContainerStack] UM.Settings.ContainerRegistry.ContainerRegistry.findContainerStacks ( self,
**Any kwargs )
Find all ContainerStack objects matching certain criteria.

:param kwargs: A dictionary of keyword arguments containing
keys and values that need to match the metadata of the ContainerStack.
An asterisk in the values can be used to denote a wildcard.

◆ findContainerStacksMetadata()

List[metadata_type] UM.Settings.ContainerRegistry.ContainerRegistry.findContainerStacksMetadata ( self,
**Any kwargs )
Find the metadata of all container stacks matching certain criteria.

:param kwargs: A dictionary of keyword arguments containing keys and
values that need to match the metadata. An asterisk in the values can be
used to denote a wildcard.
:return: A list of metadata dictionaries matching the search criteria, or
an empty list if nothing was found.

◆ findDefinitionContainers()

List[DefinitionContainerInterface] UM.Settings.ContainerRegistry.ContainerRegistry.findDefinitionContainers ( self,
**Any kwargs )
Find all DefinitionContainer objects matching certain criteria.

:param dict kwargs: A dictionary of keyword arguments containing
keys and values that need to match the metadata of the
DefinitionContainer. An asterisk in the values can be used to denote a
wildcard.

Reimplemented from UM.Settings.Interfaces.ContainerRegistryInterface.

◆ findDefinitionContainersMetadata()

List[Dict[str, Any]] UM.Settings.ContainerRegistry.ContainerRegistry.findDefinitionContainersMetadata ( self,
**Any kwargs )
Get the metadata of all definition containers matching certain criteria.

:param kwargs: A dictionary of keyword arguments containing keys and
values that need to match the metadata. An asterisk in the values can be
used to denote a wildcard.
:return: A list of metadata dictionaries matching the search criteria, or
an empty list if nothing was found.

◆ findDirtyContainers()

List[ContainerInterface] UM.Settings.ContainerRegistry.ContainerRegistry.findDirtyContainers ( self,
*bool ignore_case = False,
**Any kwargs )
Specialized find function to find only the modified container objects
that also match certain criteria.

This is faster than the normal find methods since it won't ever load all
containers, but only the modified ones. Since containers must be fully
loaded before they are modified, you are guaranteed that any operations
on the resulting containers will not trigger additional containers to
load lazily.

:param kwargs: A dictionary of keyword arguments containing
keys and values that need to match the metadata of the container. An
asterisk can be used to denote a wildcard.
:param ignore_case: Whether casing should be ignored when matching string
values of metadata.
:return: A list of containers matching the search criteria, or an empty
list if nothing was found.

◆ findInstanceContainers()

List[InstanceContainer] UM.Settings.ContainerRegistry.ContainerRegistry.findInstanceContainers ( self,
**Any kwargs )
Find all InstanceContainer objects matching certain criteria.

:param kwargs: A dictionary of keyword arguments containing
keys and values that need to match the metadata of the
InstanceContainer. An asterisk in the values can be used to denote a
wildcard.

◆ findInstanceContainersMetadata()

List[metadata_type] UM.Settings.ContainerRegistry.ContainerRegistry.findInstanceContainersMetadata ( self,
**Any kwargs )
Find the metadata of all instance containers matching certain criteria.

:param kwargs: A dictionary of keyword arguments containing keys and
values that need to match the metadata. An asterisk in the values can be
used to denote a wildcard.
:return: A list of metadata dictionaries matching the search criteria, or
an empty list if nothing was found.

◆ getCacheLockFilename()

str UM.Settings.ContainerRegistry.ContainerRegistry.getCacheLockFilename ( self)
Get the cache lock filename including full path.

◆ getContainerForMimeType()

Optional[Type[ContainerInterface]] UM.Settings.ContainerRegistry.ContainerRegistry.getContainerForMimeType ( cls,
MimeType mime_type )
Get the container type corresponding to a certain mime type.

:param mime_type: The mime type to get the container type for.

:return: A class object of a container type that corresponds to the specified mime type or None if not found.

◆ getContainerTypes()

UM.Settings.ContainerRegistry.ContainerRegistry.getContainerTypes ( cls)
Get all the registered container types

:return: A dictionary view object that provides access to the container types.
The key is the plugin ID, the value the container type.

◆ getEmptyInstanceContainer()

InstanceContainer UM.Settings.ContainerRegistry.ContainerRegistry.getEmptyInstanceContainer ( self)
This is a small convenience to make it easier to support complex structures in ContainerStacks.

Reimplemented from UM.Settings.Interfaces.ContainerRegistryInterface.

◆ getLockFilename()

str UM.Settings.ContainerRegistry.ContainerRegistry.getLockFilename ( self)
Get the lock filename including full path
Dependent on when you call this function, Resources.getConfigStoragePath may return different paths

◆ getMimeTypeForContainer()

Optional[MimeType] UM.Settings.ContainerRegistry.ContainerRegistry.getMimeTypeForContainer ( cls,
type container_type )
Retrieve the mime type corresponding to a certain container type

:param container_type: The type of container to get the mime type for.

:return: A MimeType object that matches the mime type of the container or None if not found.

◆ getResourceTypes()

Dict[str, int] UM.Settings.ContainerRegistry.ContainerRegistry.getResourceTypes ( self)
Returns all resource types.

◆ isExplicitReadOnly()

bool UM.Settings.ContainerRegistry.ContainerRegistry.isExplicitReadOnly ( self,
str container_id )

◆ isLoaded()

bool UM.Settings.ContainerRegistry.ContainerRegistry.isLoaded ( self,
str container_id )
Returns whether a container is completely loaded or not.

If only its metadata is known, it is not yet completely loaded.
:return: True if all data about this container is known, False if only
metadata is known or the container is completely unknown.

◆ isReadOnly()

bool UM.Settings.ContainerRegistry.ContainerRegistry.isReadOnly ( self,
str container_id )
Returns whether a profile is read-only or not.

Whether it is read-only depends on the source where the container is
obtained from.
:return: True if the container is read-only, or False if it can be
modified.

Reimplemented from UM.Settings.Interfaces.ContainerRegistryInterface.

◆ load()

None UM.Settings.ContainerRegistry.ContainerRegistry.load ( self)
Load all available definition containers, instance containers and
container stacks.

:note This method does not clear the internal list of containers. This means that any containers
that were already added when the first call to this method happened will not be re-added.

◆ loadAllMetadata()

None UM.Settings.ContainerRegistry.ContainerRegistry.loadAllMetadata ( self)
Load the metadata of all available definition containers, instance
containers and container stacks.

◆ lockCache()

LockFile UM.Settings.ContainerRegistry.ContainerRegistry.lockCache ( self)
Context manager to create a lock file for the cache directory and remove
it afterwards.

◆ lockFile()

LockFile UM.Settings.ContainerRegistry.ContainerRegistry.lockFile ( self)
Contextmanager to create a lock file and remove it afterwards.

◆ saveContainer()

None UM.Settings.ContainerRegistry.ContainerRegistry.saveContainer ( self,
"ContainerInterface" container,
Optional["ContainerProvider"] provider = None )
Save single dirty container

◆ saveDirtyContainers()

None UM.Settings.ContainerRegistry.ContainerRegistry.saveDirtyContainers ( self)
Save all the dirty containers by calling the appropriate container providers

◆ setExplicitReadOnly()

None UM.Settings.ContainerRegistry.ContainerRegistry.setExplicitReadOnly ( self,
str container_id )

◆ uniqueName()

str UM.Settings.ContainerRegistry.ContainerRegistry.uniqueName ( self,
str original )
Creates a new unique name for a container that doesn't exist yet.

It tries if the original name you provide exists, and if it doesn't
it'll add a "        1" or "        2" after the name to make it unique.

:param original: The original name that may not be unique.
:return: A unique name that looks a lot like the original but may have
a number behind it to make it unique.

Member Data Documentation

◆ mime_type_map

dict UM.Settings.ContainerRegistry.ContainerRegistry.mime_type_map
static
Initial value:
= {
"application/x-uranium-definitioncontainer": DefinitionContainer,
"application/x-uranium-instancecontainer": InstanceContainer,
"application/x-uranium-containerstack": ContainerStack,
"application/x-uranium-extruderstack": ContainerStack
}

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