Uranium
Application Framework
Loading...
Searching...
No Matches
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

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

Protected Attributes

 _metadata
 
 _containers
 
- Protected Attributes inherited from UM.PluginObject.PluginObject
 _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__()

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

Initialises the provider, which creates a few empty fields.

Reimplemented from UM.PluginObject.PluginObject.

Member Function Documentation

◆ __getitem__()

UM.Settings.ContainerProvider.ContainerProvider.__getitem__ (   self,
str  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__()

UM.Settings.ContainerProvider.ContainerProvider.__lt__ (   self,
"ContainerProvider"  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()

UM.Settings.ContainerProvider.ContainerProvider.addMetadata (   self,
Dict[str, Any]  metadata 
)

Adds an item to the list of metadata.

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

◆ getAllIds()

Iterable[str] UM.Settings.ContainerProvider.ContainerProvider.getAllIds (   self)

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

Returns
A list of all container IDs.

◆ getMetadata()

Optional[Dict[str, Any]] UM.Settings.ContainerProvider.ContainerProvider.getMetadata (   self,
str  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()

bool UM.Settings.ContainerProvider.ContainerProvider.isReadOnly (   self,
str  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()

"ContainerInterface" UM.Settings.ContainerProvider.ContainerProvider.loadContainer (   self,
str  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()

Dict[str, Any] UM.Settings.ContainerProvider.ContainerProvider.loadMetadata (   self,
str  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.

◆ removeContainer()

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: