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

This class serves as a database for containers. More...

Inheritance diagram for UM.Settings.ContainerProvider.ContainerProvider:
UM.PluginObject.PluginObject

Public Member Functions

def __init__ (self)
 Initialises the provider, which creates a few empty fields. More...
 
def __getitem__
 Gets a container with a specified ID. More...
 
def __lt__
 Compares container providers by their priority so that they are easy to sort. More...
 
def __eq__
 
def addMetadata
 Adds an item to the list of metadata. More...
 
def getMetadata
 Gets the metadata of a specified container. More...
 
def getAllIds (self)
 Gets a list of IDs of all containers this provider provides. More...
 
def isReadOnly
 Returns whether a container is considered read-only by this provider. More...
 
def loadContainer
 Loads the container with the specified ID. More...
 
def loadMetadata
 Loads the metadata of a specified container. More...
 
def metadata (self)
 Gets a dictionary of metadata of all containers, indexed by ID. More...
 
def removeContainer (self, container_id)
 Delete a container from this provider. More...
 
- Public Member Functions inherited from UM.PluginObject.PluginObject
def __init__ (self)
 
def getPluginId (self)
 
def setPluginId (self, plugin_id)
 

Detailed Description

This class serves as a database for containers.

A plug-in can define a new source for containers by implementing the getAllIds, loadMetadata and loadContainer methods.

Constructor & Destructor Documentation

◆ __init__()

def UM.Settings.ContainerProvider.ContainerProvider.__init__ (   self)

Initialises the provider, which creates a few empty fields.

Member Function Documentation

◆ __getitem__()

def UM.Settings.ContainerProvider.ContainerProvider.__getitem__ (   self,
  container_id 
)

Gets a container with a specified ID.

This should be implemented lazily. An implementation should first check

Parameters
container_idThe ID of a container to get.
Returns
The specified container.

◆ __lt__()

def UM.Settings.ContainerProvider.ContainerProvider.__lt__ (   self,
  other 
)

Compares container providers by their priority so that they are easy to sort.

Parameters
otherThe other container provider to compare with.
Returns
A positive number if this provider has lower priority than the other, or a negative number if this provider has higher priority than the other.

◆ addMetadata()

def UM.Settings.ContainerProvider.ContainerProvider.addMetadata (   self,
  metadata 
)

Adds an item to the list of metadata.

This is intended to be called from the implementation of loadMetadata.

◆ getAllIds()

def UM.Settings.ContainerProvider.ContainerProvider.getAllIds (   self,
  Iterable,
  str 
)

Gets a list of IDs of all containers this provider provides.

Returns
A list of all container IDs.

◆ getMetadata()

def UM.Settings.ContainerProvider.ContainerProvider.getMetadata (   self,
  container_id 
)

Gets the metadata of a specified container.

If the metadata of the container doesn't exist yet, it is loaded from the container source by the implementation of the provider.

Note that due to inheritance, this may also trigger the metadata of other containers to load.

Parameters
container_idThe container to get the metadata of.
Returns
A dictionary of metadata for this container, or None if it failed to load.

◆ isReadOnly()

def UM.Settings.ContainerProvider.ContainerProvider.isReadOnly (   self,
  container_id 
)

Returns whether a container is considered read-only by this provider.

Some providers don't allow modifying their containers at all. Some only allow some containers to be modified.

Returns
Whether the specified container is read-only.

◆ loadContainer()

def UM.Settings.ContainerProvider.ContainerProvider.loadContainer (   self,
  container_id 
)

Loads the container with the specified ID.

This is called lazily, so it should only request to load each container once and only when it's really needed. The container must be fully loaded after this is completed, so it may take some time.

Returns
The fully loaded container.

◆ loadMetadata()

def UM.Settings.ContainerProvider.ContainerProvider.loadMetadata (   self,
  container_id 
)

Loads the metadata of a specified container.

This will be called during start-up. It should be efficient.

Parameters
container_idThe ID of the container to load the metadata of.
Returns
A dictionary of metadata dictionaries, indexed by their IDs.

◆ metadata()

def UM.Settings.ContainerProvider.ContainerProvider.metadata (   self,
  Dict,
  str,
  Dict,
  str,
  Any 
)

Gets a dictionary of metadata of all containers, indexed by ID.

◆ removeContainer()

def UM.Settings.ContainerProvider.ContainerProvider.removeContainer (   self,
  container_id 
)

Delete a container from this provider.

This deletes the container from the source. If it's read only, this should give an exception.

Parameters
container_idThe ID of the container to remove.

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