Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Settings.DefinitionContainer.DefinitionContainer Class Reference

A container for SettingDefinition objects. More...

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

Public Member Functions

 __init__ (self, str container_id, i18n_catalog=None, *args, **kwargs)
 Constructor.
 
 __setattr__ (self, name, value)
 Reimplement setattr so we can make sure the definition remains unchanged after creation.
 
 __getnewargs__ (self)
 For pickle support.
 
 __getstate__ (self)
 For pickle support.
 
 __setstate__ (self, state)
 For pickle support.
 
str getId (self)
 
str getName (self)
 
bool isReadOnly (self)
 
None setReadOnly (self, bool read_only)
 
 getPath (self)
 
 setPath (self, path)
 
 getMetaData (self)
 
 definitions (self)
 
 getInheritedFiles (self)
 Gets all ancestors of this definition container.
 
List[str] getAllKeys (self)
 Gets all keys of settings in this container.
 
 getMetaDataEntry (self, entry, default=None)
 
 getProperty (self, key, property_name, context=None)
 
 hasProperty (self, key, property_name, bool ignore_inherited=False)
 
 serialize (self, Optional[set] ignored_metadata_keys=None)
 
Optional[str] getConfigurationTypeFromSerialized (cls, str serialized)
 Gets the configuration type of the given serialized data.
 
Optional[int] getVersionFromSerialized (cls, str serialized)
 Gets the version of the given serialized data.
 
 addDefinition (self, SettingDefinition definition)
 Add a setting definition instance if it doesn't exist yet.
 
str deserialize (self, serialized, Optional[str] file_name=None)
 
List[Dict[str, Any]] deserializeMetadata (cls, str serialized, str container_id)
 Gets the metadata of a definition container from a serialised format.
 
List[SettingDefinitionfindDefinitions (self, **kwargs)
 Find definitions matching certain criteria.
 
int getLoadingPriority (cls)
 
 __str__ (self)
 Simple short string representation for debugging purposes.
 
- Public Member Functions inherited from UM.PluginObject.PluginObject
 __init__ (self)
 
 getPluginId (self)
 
 setPluginId (self, plugin_id)
 

Public Attributes

 Version
 

Static Public Attributes

int Version = 2
 
 id = pyqtProperty(str, fget = getId, constant = True)
 
 name = pyqtProperty(str, fget = getName, constant = True)
 
 readOnly = pyqtProperty(bool, fget = isReadOnly, constant = True)
 
 metaData = pyqtProperty("QVariantMap", fget = getMetaData, constant = True)
 
 propertyChanged = Signal()
 This signal is unused since the definition container is immutable, but is provided for API consistency.
 
 metaDataChanged = Signal()
 

Protected Member Functions

dict _readAndValidateSerialized (self, str serialized)
 
 _preprocessParsedJson (self, parsed)
 
dict _loadFile (self, str file_name)
 
dict _resolveInheritance (self, str file_name)
 
 _verifyJson (cls, Dict[str, Any] json_dict)
 
 _findInDict (self, dict dictionary, str key)
 
 _mergeDicts (self, dict first, dict second)
 
 _updateRelations (self, SettingDefinition definition)
 
 _processFunction (self, SettingDefinition definition, str property)
 
SettingDefinition _getDefinition (self, str key)
 

Protected Attributes

 _metadata
 
 _definitions
 
 _inherited_files
 
 _i18n_catalog
 
 _definition_cache
 
 _path
 
- Protected Attributes inherited from UM.PluginObject.PluginObject
 _plugin_id
 

Detailed Description

A container for SettingDefinition objects.

Constructor & Destructor Documentation

◆ __init__()

UM.Settings.DefinitionContainer.DefinitionContainer.__init__ (   self,
str  container_id,
  i18n_catalog = None,
args,
**  kwargs 
)

Constructor.

Parameters
container_idA unique, machine readable/writable ID for this container.

Reimplemented from UM.PluginObject.PluginObject.

Member Function Documentation

◆ addDefinition()

UM.Settings.DefinitionContainer.DefinitionContainer.addDefinition (   self,
SettingDefinition  definition 
)

Add a setting definition instance if it doesn't exist yet.

Warning: this might not work when there are relationships higher up in the stack.

◆ deserialize()

str UM.Settings.DefinitionContainer.DefinitionContainer.deserialize (   self,
  serialized,
Optional[str]   file_name = None 
)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ deserializeMetadata()

List[Dict[str, Any]] UM.Settings.DefinitionContainer.DefinitionContainer.deserializeMetadata (   cls,
str  serialized,
str  container_id 
)

Gets the metadata of a definition container from a serialised format.

This parses the entire JSON document and only extracts the metadata from it.

Parameters
serializedA JSON document, serialised as a string.
container_idThe ID of the container (as obtained from the file name).
Returns
A dictionary of metadata that was in the JSON document in a singleton list. If anything went wrong, the list will be empty.

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ findDefinitions()

List[SettingDefinition] UM.Settings.DefinitionContainer.DefinitionContainer.findDefinitions (   self,
**  kwargs 
)

Find definitions matching certain criteria.

Parameters
kwargsdict A dictionary of keyword arguments containing key-value pairs which should match properties of the definition.

◆ getAllKeys()

List[str] UM.Settings.DefinitionContainer.DefinitionContainer.getAllKeys (   self)

Gets all keys of settings in this container.

Returns
A set of all keys of settings in this container.

◆ getConfigurationTypeFromSerialized()

Optional[str] UM.Settings.DefinitionContainer.DefinitionContainer.getConfigurationTypeFromSerialized (   cls,
str  serialized 
)

Gets the configuration type of the given serialized data.

(used by __updateSerialized())

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getId()

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

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getInheritedFiles()

UM.Settings.DefinitionContainer.DefinitionContainer.getInheritedFiles (   self)

Gets all ancestors of this definition container.

This returns the definition in the "inherits" property of this container, and the definition in its "inherits" property, and so on. The ancestors are returned in order from parent to grand-grand-grand-...-grandparent, normally ending in a "root" container.

Returns
A list of ancestors, in order from near ancestor to the root.

◆ getLoadingPriority()

int UM.Settings.DefinitionContainer.DefinitionContainer.getLoadingPriority (   cls)

◆ getMetaData()

UM.Settings.DefinitionContainer.DefinitionContainer.getMetaData (   self)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getMetaDataEntry()

UM.Settings.DefinitionContainer.DefinitionContainer.getMetaDataEntry (   self,
  entry,
  default = None 
)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getName()

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

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getPath()

UM.Settings.DefinitionContainer.DefinitionContainer.getPath (   self)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getProperty()

UM.Settings.DefinitionContainer.DefinitionContainer.getProperty (   self,
  key,
  property_name,
  context = None 
)

Reimplemented from ContainerInterface.

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getVersionFromSerialized()

Optional[int] UM.Settings.DefinitionContainer.DefinitionContainer.getVersionFromSerialized (   cls,
str  serialized 
)

Gets the version of the given serialized data.

(used by __updateSerialized())

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ hasProperty()

UM.Settings.DefinitionContainer.DefinitionContainer.hasProperty (   self,
  key,
  property_name,
bool   ignore_inherited = False 
)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ isReadOnly()

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

Reimplemented from ContainerInterface

◆ serialize()

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

TODO: This implementation flattens the definition container, since the data about inheritance and overrides was lost when deserialising.

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ setPath()

UM.Settings.DefinitionContainer.DefinitionContainer.setPath (   self,
  path 
)

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.


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