Uranium
Application Framework
|
This class serves as a database for containers. More...
Public Member Functions | |
def | __init__ (self) |
Initialises the provider, which creates a few empty fields. More... | |
def | __getitem__ (self, str container_id) |
Gets a container with a specified ID. More... | |
def | __lt__ (self, "ContainerProvider" other) |
Compares container providers by their priority so that they are easy to sort. More... | |
def | __eq__ (self, "ContainerProvider" other) |
def | addMetadata (self, Dict[str, Any] metadata) |
Adds an item to the list of metadata. More... | |
Optional[Dict[str, Any]] | getMetadata (self, str container_id) |
Gets the metadata of a specified container. More... | |
Iterable[str] | getAllIds (self) |
Gets a list of IDs of all containers this provider provides. More... | |
bool | isReadOnly (self, str container_id) |
Returns whether a container is considered read-only by this provider. More... | |
"ContainerInterface" | loadContainer (self, str container_id) |
Loads the container with the specified ID. More... | |
Dict[str, Any] | loadMetadata (self, str container_id) |
Loads the metadata of a specified container. More... | |
Dict[str, Dict[str, Any]] | 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... | |
![]() | |
def | getPluginId (self) |
def | setPluginId (self, plugin_id) |
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.
def UM.Settings.ContainerProvider.ContainerProvider.__init__ | ( | self | ) |
Initialises the provider, which creates a few empty fields.
Reimplemented from UM.PluginObject.PluginObject.
def 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
container_id | The ID of a container to get. |
def UM.Settings.ContainerProvider.ContainerProvider.__lt__ | ( | self, | |
"ContainerProvider" | other | ||
) |
Compares container providers by their priority so that they are easy to sort.
other | The other container provider to compare with. |
def 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
.
Iterable[str] UM.Settings.ContainerProvider.ContainerProvider.getAllIds | ( | self | ) |
Gets a list of IDs of all containers this provider provides.
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.
container_id | The container to get the metadata of. |
None
if it failed to load. 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.
"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.
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.
container_id | The ID of the container to load the metadata of. |
Dict[str, Dict[str, Any]] UM.Settings.ContainerProvider.ContainerProvider.metadata | ( | self | ) |
Gets a dictionary of metadata of all containers, indexed by ID.
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.
container_id | The ID of the container to remove. |