Uranium
Application Framework
Loading...
Searching...
No Matches
UM.Resources.Resources Class Reference

Public Member Functions

str getPath (cls, int resource_type, *args)
 
List[str] getAllResourcesOfType (cls, int resource_type)
 
str getStoragePath (cls, int resource_type, *args)
 
List[str] getAllPathsForType (cls, int resource_type)
 
str getStoragePathForType (cls, int resource_type)
 
None addSearchPath (cls, str path)
 
None addSecureSearchPath (cls, str path)
 
None removeSearchPath (cls, str path)
 
None addType (cls, int resource_type, str path)
 
None addStorageType (cls, int resource_type, str path)
 
str getConfigStoragePath (cls)
 
str getDataStoragePath (cls)
 
str getCacheStoragePath (cls)
 
Generator[str, None, None] getSearchPaths (cls)
 
Generator[str, None, None] getSecureSearchPaths (cls)
 
None removeType (cls, int resource_type)
 
None factoryReset (cls)
 
None copyVersionFolder (cls, str src_path, str dest_path)
 
None addExpectedDirNameInData (cls, str dir_name)
 
None setIsEnterprise (cls, bool is_enterprise)
 

Public Attributes

 ApplicationIdentifier
 
 ApplicationVersion
 

Static Public Attributes

int Preferences = 2
 
int Meshes = 3
 
int Shaders = 4
 
int i18n = 5
 
int Images = 6
 
int Themes = 7
 
int DefinitionContainers = 8
 
int InstanceContainers = 9
 
int ContainerStacks = 10
 
int Cache = 11
 
int Plugins = 12
 
int BundledPackages = 13
 
int Texts = 14
 
int UserType = 128
 
str ApplicationIdentifier = "UM"
 
str ApplicationVersion = "unknown"
 

Protected Member Functions

str _getConfigStorageRootPath (cls)
 
List[str] _getPossibleConfigStorageRootPathList (cls)
 
List[str] _getPossibleDataStorageRootPathList (cls)
 
Optional[str] _getDataStorageRootPath (cls)
 
Optional[str] _getCacheStorageRootPath (cls)
 
None _copyLatestDirsIfPresent (cls)
 
Optional[str] _findLatestDirInPaths (cls, List[str] search_path_list, str dir_type="config")
 
bool _isNonVersionedDataDir (cls, str check_path)
 
bool _isNonVersionedConfigDir (cls, str check_path)
 

Detailed Description

Class to look up any form of resource used by Uranium or an application using Uranium

Member Function Documentation

◆ _copyLatestDirsIfPresent()

None UM.Resources.Resources._copyLatestDirsIfPresent ( cls)
protected
Copies the directories of the latest version on this machine if present, so the upgrade will use the copies
as the base for upgrade. See CURA-3529 for more details.

◆ addSearchPath()

None UM.Resources.Resources.addSearchPath ( cls,
str path )
Add a path relative to which resources should be searched for.

:param path: The path to add.

◆ addSecureSearchPath()

None UM.Resources.Resources.addSecureSearchPath ( cls,
str path )
Add a path relative to which resources should be searched for.
This path should be secure, such as the install directory.

:param path: The path to add.

◆ addStorageType()

None UM.Resources.Resources.addStorageType ( cls,
int resource_type,
str path )
Add a custom storage path for a resource type.

:param resource_type: The type to add a storage path for.
:param path: The path to add as storage path. Should be relative to the resources storage path.

◆ addType()

None UM.Resources.Resources.addType ( cls,
int resource_type,
str path )
Add a custom resource type that can be located.

:param resource_type: An integer that can be used to identify the type. Should be greater than UserType.
:param path: The path relative to the search paths where resources of this type can be found./

◆ factoryReset()

None UM.Resources.Resources.factoryReset ( cls)
Performs a factory reset, compressing the current state of configuration
into an archive and emptying the resource folders.

When calling this function, be sure to quit the application immediately
afterwards, lest the save function write the configuration anew.

◆ getAllPathsForType()

List[str] UM.Resources.Resources.getAllPathsForType ( cls,
int resource_type )
Return a list of paths for a certain resource type.

:param resource_type: The type of resource to retrieve.
:return: A list of absolute paths where the resource type can be found.

:exception TypeError Raised when type is an unknown value.

◆ getAllResourcesOfType()

List[str] UM.Resources.Resources.getAllResourcesOfType ( cls,
int resource_type )
Get a list of paths to all resources of a certain resource type.

:param resource_type: The resource type to get the paths for.

:return: A list of absolute paths to resources of the specified type.

◆ getCacheStoragePath()

str UM.Resources.Resources.getCacheStoragePath ( cls)
Gets the cache storage path.

This is where the application stores cache files.

◆ getConfigStoragePath()

str UM.Resources.Resources.getConfigStoragePath ( cls)
Gets the configuration storage path.

This is where the application stores user configuration, such as
preferences.

◆ getDataStoragePath()

str UM.Resources.Resources.getDataStoragePath ( cls)
Gets the data storage path.

This is where the application stores user files, such as profiles.

◆ getPath()

str UM.Resources.Resources.getPath ( cls,
int resource_type,
* args )
Get the path to a certain resource file

:param resource_type: :type{int} The type of resource to retrieve a path for.
:param args: Arguments that are appended to the location to locate the correct file.

:return: An absolute path to a file.
    If a file exists in any storage path, it is returned without searching other paths.
    If multiple files are found the first found is returned.

:exception FileNotFoundError: Raised when the file could not be found.

◆ getSearchPaths()

Generator[str, None, None] UM.Resources.Resources.getSearchPaths ( cls)
Gets the search paths for resources.

:return: A sequence of paths where resources might be.

◆ getSecureSearchPaths()

Generator[str, None, None] UM.Resources.Resources.getSecureSearchPaths ( cls)
Gets the secure search paths for resources.

:return: A sequence of paths where resources might be.

◆ getStoragePath()

str UM.Resources.Resources.getStoragePath ( cls,
int resource_type,
* args )
Get the path that can be used to write a certain resource file.

:param resource_type: The type of resource to retrieve a path for.
:param args: Arguments that are appended to the location for the correct path.

:return: A path that can be used to write the file.

:note This method does not check whether a given file exists.

◆ getStoragePathForType()

str UM.Resources.Resources.getStoragePathForType ( cls,
int resource_type )
Return a path where a certain resource type can be stored.

:param type: The type of resource to store.
:return: An absolute path where the given resource type can be stored.

:exception UnsupportedStorageTypeError Raised when writing type is not supported.

◆ removeSearchPath()

None UM.Resources.Resources.removeSearchPath ( cls,
str path )
Remove a resource search path.

◆ removeType()

None UM.Resources.Resources.removeType ( cls,
int resource_type )
Remove a custom resource type.

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