Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Settings.DefinitionContainer.DefinitionContainer Class Reference
Inheritance diagram for UM.Settings.DefinitionContainer.DefinitionContainer:
UM.PluginObject.PluginObject

Public Member Functions

None __init__ (self, str container_id, i18nCatalog i18n_catalog=None, QObject parent=None, *args, **kwargs)
None __setattr__ (self, str name, Any value)
Tuple[str, Optional[i18nCatalog]] __getnewargs__ (self)
Dict[str, Any] __getstate__ (self)
None __setstate__ (self, Dict[str, Any] state)
str getId (self)
str getName (self)
bool isReadOnly (self)
None setReadOnly (self, bool read_only)
str getPath (self)
None setPath (self, str path)
Dict[str, Any] getMetaData (self)
List[SettingDefinitiondefinitions (self)
List[str] getInheritedFiles (self)
Set[str] getAllKeys (self)
Any getMetaDataEntry (self, str entry, Any default=None)
Any getProperty (self, str key, str property_name, PropertyEvaluationContext context=None)
Any hasProperty (self, str key, str property_name, bool ignore_inherited=False)
str serialize (self, Optional[Set[str]] ignored_metadata_keys=None)
Optional[str] getConfigurationTypeFromSerialized (cls, str serialized)
Tuple[Dict[str, Any], bool] readAndValidateSerialized (self, str serialized)
Optional[int] getVersionFromSerialized (cls, str serialized)
None addDefinition (self, SettingDefinition definition)
str deserialize (self, str serialized, Optional[str] file_name=None)
None appendAdditionalSettingDefinitions (self, Dict[str, Dict[str, Any]] additional_settings)
List[Dict[str, Any]] deserializeMetadata (cls, str serialized, str container_id)
List[SettingDefinitionfindDefinitions (self, **Any kwargs)
int getLoadingPriority (cls)
bool isDirty (self)
str __str__ (self)
str __repr__ (self)
int __hash__ (self)
Public Member Functions inherited from UM.PluginObject.PluginObject
None __init__ (self, *args, **kwags)
None setPluginId (self, str plugin_id)
None setMetaData (self, Dict[str, Any] metadata)
str getPluginId (self)
None setVersion (self, str version)
str getVersion (self)

Public Attributes

 definitions

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)

Protected Member Functions

bool _preprocessParsedJson (self, Dict[str, Any] parsed)
List[SettingDefinition_deserializeDefinitions (self, Dict[str, Any] settings_dict, Optional[str] force_category=None)
Dict[str, Any] _loadFile (self, str file_name)
Dict[str, Any] _resolveInheritance (self, str file_name)
 _verifyJson (self, Dict[str, Any] json_dict)
Any _findInDict (self, Dict[str, Any] dictionary, str key)
Dict[Any, Any] _mergeDicts (self, Dict[Any, Any] first, Dict[Any, Any] second, new_dict=True)
None _updateRelations (self, SettingDefinition definition)
None _processFunction (self, SettingDefinition definition, str property_name)
Optional[SettingDefinition_getDefinition (self, str key)

Protected Attributes

list _definitions = []
list _inherited_files = []
 _i18n_catalog = i18n_catalog
dict _definition_cache = {}
str _path = ""
Protected Attributes inherited from UM.PluginObject.PluginObject
 _plugin_id = None
 _version = None
dict _metadata = {}
 _name = None

Detailed Description

A container for SettingDefinition objects.

Constructor & Destructor Documentation

◆ __init__()

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

:param container_id: A unique, machine readable/writable ID for this container.

Member Function Documentation

◆ __getnewargs__()

Tuple[str, Optional[i18nCatalog]] UM.Settings.DefinitionContainer.DefinitionContainer.__getnewargs__ ( self)
For pickle support

◆ __getstate__()

Dict[str, Any] UM.Settings.DefinitionContainer.DefinitionContainer.__getstate__ ( self)
For pickle support

◆ __setattr__()

None UM.Settings.DefinitionContainer.DefinitionContainer.__setattr__ ( self,
str name,
Any value )
Reimplement __setattr__ so we can make sure the definition remains unchanged after creation.

◆ __setstate__()

None UM.Settings.DefinitionContainer.DefinitionContainer.__setstate__ ( self,
Dict[str, Any] state )
For pickle support

◆ __str__()

str UM.Settings.DefinitionContainer.DefinitionContainer.__str__ ( self)
Simple short string representation for debugging purposes.

◆ _mergeDicts()

Dict[Any, Any] UM.Settings.DefinitionContainer.DefinitionContainer._mergeDicts ( self,
Dict[Any, Any] first,
Dict[Any, Any] second,
new_dict = True )
protected
Recursively merge a dictionary. It will return a new dict if new_dict is true (default)
:param first: First dictionary to merge
:param second: Second dictionary
:param new_dict: Should a new dict be created or should the first dict be updated in place?
:return: Merged dict

◆ addDefinition()

None 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.

◆ appendAdditionalSettingDefinitions()

None UM.Settings.DefinitionContainer.DefinitionContainer.appendAdditionalSettingDefinitions ( self,
Dict[str, Dict[str, Any]] additional_settings )
Appends setting-definitions not defined for/by the main program (for example, a plugin) to this container.

Additional settings are always assumed to come in the form of categories with child-settings.
See also the Settings.AdditionalSettingDefinitionAppender class.

:param additional_settings: A dictionary of category-name to categories, each containing setting-definitions.

◆ deserialize()

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

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.

:param serialized: A JSON document, serialised as a string.
:param container_id: The ID of the container (as obtained from the file name).

:return: 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,
**Any kwargs )
Find definitions matching certain criteria.

:param kwargs: A dictionary of keyword arguments containing key-value pairs which should match properties of
the definition.

◆ getAllKeys()

Set[str] UM.Settings.DefinitionContainer.DefinitionContainer.getAllKeys ( self)
:copydoc DefinitionContainerInterface::getAllKeys

:return: A set of all keys of settings in this container.

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ 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)
:copydoc ContainerInterface::getId

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getInheritedFiles()

List[str] 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.

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

◆ getLoadingPriority()

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

◆ getMetaData()

Dict[str, Any] UM.Settings.DefinitionContainer.DefinitionContainer.getMetaData ( self)
:copydoc ContainerInterface::getMetaData

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getMetaDataEntry()

Any UM.Settings.DefinitionContainer.DefinitionContainer.getMetaDataEntry ( self,
str entry,
Any default = None )
:copydoc ContainerInterface::getMetaDataEntry

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getName()

str UM.Settings.DefinitionContainer.DefinitionContainer.getName ( self)
:copydoc ContainerInterface::getName

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getPath()

str UM.Settings.DefinitionContainer.DefinitionContainer.getPath ( self)
:copydoc ContainerInterface::getPath.

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ getProperty()

Any UM.Settings.DefinitionContainer.DefinitionContainer.getProperty ( self,
str key,
str property_name,
PropertyEvaluationContext context = None )
:copydoc ContainerInterface::getProperty

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()

Any UM.Settings.DefinitionContainer.DefinitionContainer.hasProperty ( self,
str key,
str property_name,
bool ignore_inherited = False )
:copydoc ContainerInterface::hasProperty

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.

◆ isDirty()

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

◆ isReadOnly()

bool UM.Settings.DefinitionContainer.DefinitionContainer.isReadOnly ( self)
:copydoc ContainerInterface::isReadOnly

Reimplemented from ContainerInterface

◆ serialize()

str UM.Settings.DefinitionContainer.DefinitionContainer.serialize ( self,
Optional[Set[str]] ignored_metadata_keys = None )
:copydoc ContainerInterface::serialize

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()

None UM.Settings.DefinitionContainer.DefinitionContainer.setPath ( self,
str path )
:copydoc ContainerInterface::setPath

Reimplemented from ContainerInterface

Reimplemented from UM.Settings.Interfaces.ContainerInterface.


The documentation for this class was generated from the following file:
  • UM/Settings/DefinitionContainer.py