Base Directories
The XDG Base Directory Speicification provides standard locations to store application data, configuration, and cached data.
Data directories
XDGSpec.BaseDirectory.save_data_path
— Functionsave_data_path(resource...)
Ensure $XDG_DATA_HOME/<resource>/
exists, and return its path. 'resource' should normally be the name of your application or a shared resource. Use this when saving or updating application data.
XDGSpec.BaseDirectory.load_data_paths
— Functionload_data_paths(resource...)
Returns an iterator which gives each directory named 'resource' in the application data search path. Information provided by earlier directories should take precedence over later ones.
XDGSpec.BaseDirectory.xdg_data_home
— Constant$XDG_DATA_HOME
or the default, ~/.local/share
XDGSpec.BaseDirectory.xdg_data_dirs
— ConstantA list of directory paths in which application data may be stored, in preference order.
Configuration directories
XDGSpec.BaseDirectory.save_config_path
— Functionsave_config_path(resource...)
Ensure $XDG_CONFIG_HOME/<resource>/
exists, and return its path. 'resource' should normally be the name of your application. Use this when saving configuration settings.
XDGSpec.BaseDirectory.load_config_paths
— Functionload_config_paths(resource...)
Returns an iterator which gives each directory named 'resource' in the configuration search path. Information provided by earlier directories should take precedence over later ones, and the user-specific config dir comes first.
XDGSpec.BaseDirectory.load_first_config
— Functionfunction load_first_config(resource...)
Returns the first result from loadconfigpaths, or None if there is nothing to load.
XDGSpec.BaseDirectory.xdg_config_home
— Constant$XDG_CONFIG_HOME
or the default, ~/.config
XDGSpec.BaseDirectory.xdg_config_dirs
— ConstantA list of directory paths in which configuration may be stored, in preference order.
Cache directory
XDGSpec.BaseDirectory.save_cache_path
— Functionsave_cache_path(resource...)
Ensure $XDG_CACHE_HOME/<resource>/
exists, and return its path. 'resource' should normally be the name of your application or a shared resource.
XDGSpec.BaseDirectory.xdg_cache_home
— Constant$XDG_CACHE_HOME
or the default, ~/.cache
Runtime directory
XDGSpec.BaseDirectory.get_runtime_dir
— Functionget_runtime_dir()
Returns the value of $XDG_RUNTIME_DIR
, a directory path.
This directory is intended for 'user-specific non-essential runtime files and other file objects (such as sockets, named pipes, ...)', and 'communication and synchronization purposes'.