Uranium
Application Framework
UM.Resources.Resources Class Reference

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

Public Member Functions

str getPath (cls, int resource_type, *args)
 Get the path to a certain resource file. More...
 
List[str] getAllResourcesOfType (cls, int resource_type)
 Get a list of paths to all resources of a certain resource type. More...
 
str getStoragePath (cls, int resource_type, *args)
 Get the path that can be used to write a certain resource file. More...
 
List[str] getAllPathsForType (cls, int resource_type)
 Return a list of paths for a certain resource type. More...
 
str getStoragePathForType (cls, int resource_type)
 Return a path where a certain resource type can be stored. More...
 
None addSearchPath (cls, str path)
 Add a path relative to which resources should be searched for. More...
 
None removeSearchPath (cls, str path)
 Remove a resource search path. More...
 
None addType (cls, int resource_type, str path)
 Add a custom resource type that can be located. More...
 
None addStorageType (cls, int resource_type, str path)
 Add a custom storage path for a resource type. More...
 
str getConfigStoragePath (cls)
 Gets the configuration storage path. More...
 
str getDataStoragePath (cls)
 Gets the data storage path. More...
 
str getCacheStoragePath (cls)
 Gets the cache storage path. More...
 
Generator[str, None, None] getSearchPaths (cls)
 Gets the search paths for resources. More...
 
None removeType (cls, int resource_type)
 Remove a custom resource type. More...
 
None factoryReset (cls)
 Performs a factory reset, compressing the current state of configuration into an archive and emptying the resource folders. More...
 
None copyVersionFolder (cls, str src_path, str dest_path)
 
None addExpectedDirNameInData (cls, str dir_name)
 

Public Attributes

 ApplicationVersion
 

Static Public Attributes

int Resources = 1
 The main resources location. More...
 
int Preferences = 2
 Location of preference configuration files. More...
 
int Meshes = 3
 Location of meshes. More...
 
int Shaders = 4
 Location of shaders. More...
 
int i18n = 5
 Location of translation files. More...
 
int Images = 6
 Location of images not in the theme. More...
 
int Themes = 7
 Location of themes. More...
 
int DefinitionContainers = 8
 Location of definition container files. More...
 
int InstanceContainers = 9
 Location of instance container files. More...
 
int ContainerStacks = 10
 Location of container stack files. More...
 
int Cache = 11
 Location of cached data.
 
int Plugins = 12
 Location of plugins.
 
int BundledPackages = 13
 Location of data regarding bundled packages.
 
int Texts = 14
 Location of text files.
 
int UserType = 128
 Any custom resource types should be greater than this to prevent collisions with standard types. More...
 
string ApplicationIdentifier = "UM"
 
string ApplicationVersion = "unknown"
 

Detailed Description

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

Member Function Documentation

◆ addSearchPath()

None UM.Resources.Resources.addSearchPath (   cls,
str  path 
)

Add a path relative to which resources should be searched for.

Parameters
pathThe path to add.

◆ addStorageType()

None UM.Resources.Resources.addStorageType (   cls,
int  resource_type,
str  path 
)

Add a custom storage path for a resource type.

Parameters
typeThe type to add a storage path for.
pathThe 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.

Parameters
typeint An integer that can be used to identify the type. Should be greater than UserType.
pathstring 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.

Parameters
resource_typeint The type of resource to retrieve.
Returns
list A list of absolute paths where the resource type can be found.
Exceptions
TypeErrorRaised 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.

Parameters
resource_typeThe resource type to get the paths for.
Returns
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.

Parameters
resource_typeint The type of resource to retrieve a path for.
argsArguments that are appended to the location to locate the correct file.
Returns
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.
Exceptions
FileNotFoundErrorRaised when the file could not be found.

◆ getSearchPaths()

Generator[str, None, None] UM.Resources.Resources.getSearchPaths (   cls)

Gets the search paths for resources.

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

Parameters
resource_typeThe type of resource to retrieve a path for.
argsArguments that are appended to the location for the correct path.
Returns
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.

Parameters
typeThe type of resource to store.
Returns
An absolute path where the given resource type can be stored.
Exceptions
UnsupportedStorageTypeErrorRaised 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.

Member Data Documentation

◆ ContainerStacks

int UM.Resources.Resources.ContainerStacks = 10
static

Location of container stack files.

Equal to $resources/stacks

◆ DefinitionContainers

int UM.Resources.Resources.DefinitionContainers = 8
static

Location of definition container files.

Equal to $resources/definitions

◆ i18n

int UM.Resources.Resources.i18n = 5
static

Location of translation files.

Equal to $resources/i18n.

◆ Images

int UM.Resources.Resources.Images = 6
static

Location of images not in the theme.

Equal to $resources/images.

◆ InstanceContainers

int UM.Resources.Resources.InstanceContainers = 9
static

Location of instance container files.

Equal to $resources/instances

◆ Meshes

int UM.Resources.Resources.Meshes = 3
static

Location of meshes.

Equal to $resources/meshes.

◆ Preferences

int UM.Resources.Resources.Preferences = 2
static

Location of preference configuration files.

Actual location depends on platform.

◆ Resources

int UM.Resources.Resources.Resources = 1
static

The main resources location.

Equal to $resource_search_path/resources.

◆ Shaders

int UM.Resources.Resources.Shaders = 4
static

Location of shaders.

Equal to $resources/shaders.

◆ Themes

int UM.Resources.Resources.Themes = 7
static

Location of themes.

Equal to $resources/themes.

◆ UserType

int UM.Resources.Resources.UserType = 128
static

Any custom resource types should be greater than this to prevent collisions with standard types.


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