Package zeroinstall :: Package support :: Module basedir
[frames] | no frames]

Module basedir

source code

Support code for the freedesktop.org basedir spec.

This module provides functions for locating configuration files.


See Also: http://freedesktop.org/wiki/Standards/basedir-spec

Functions
str
save_config_path(*resource)
Ensure $XDG_CONFIG_HOME/<resource>/ exists, and return its path.
source code
 
load_config_paths(*resource)
Returns an iterator which gives each directory named 'resource' in the configuration search path.
source code
str | None
load_first_config(*resource)
Returns the first result from load_config_paths, or None if there is nothing to load.
source code
str
save_cache_path(*resource)
Ensure $XDG_CACHE_HOME/<resource>/ exists, and return its path.
source code
 
load_cache_paths(*resource)
Returns an iterator which gives each directory named 'resource' in the cache search path.
source code
str | None
load_first_cache(*resource)
Returns the first result from load_cache_paths, or None if there is nothing to load.
source code
 
load_data_paths(*resource)
Returns an iterator which gives each directory named 'resource' in the shared data search path.
source code
str | None
load_first_data(*resource)
Returns the first result from load_data_paths, or None if there is nothing to load.
source code
str
save_data_path(*resource)
Ensure $XDG_DATA_HOME/<resource>/ exists, and return its path.
source code
Variables
  home = pwd.getpwuid(0).pw_dir or '/'
The value of $HOME (or '/' if not set).
  portable_base = os.environ.get('ZEROINSTALL_PORTABLE_BASE')
  appData = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0)
  localAppData = shell.SHGetFolderPath(0, shellcon.CSIDL_LOCAL_A...
  commonAppData = shell.SHGetFolderPath(0, shellcon.CSIDL_COMMON...
  xdg_data_dirs = _get_path('XDG_DATA_HOME', 'XDG_DATA_DIRS', _d...
  xdg_cache_dirs = _get_path('XDG_CACHE_HOME', 'XDG_CACHE_DIRS',...
  xdg_config_dirs = _get_path('XDG_CONFIG_HOME', 'XDG_CONFIG_DIR...
  xdg_data_home = xdg_data_dirs [0]
  xdg_cache_home = xdg_cache_dirs [0]
  xdg_config_home = xdg_config_dirs [0]
Function Details

save_config_path(*resource)

source code 

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. Use the xdg_config_dirs variable for loading.

Returns: str

load_config_paths(*resource)

source code 

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 (ie, the user's config dir comes first).

save_cache_path(*resource)

source code 

Ensure $XDG_CACHE_HOME/<resource>/ exists, and return its path. 'resource' should normally be the name of your application.

Returns: str

load_cache_paths(*resource)

source code 

Returns an iterator which gives each directory named 'resource' in the cache search path. Information provided by earlier directories should take precedence over later ones (ie, the user's cache dir comes first).

load_data_paths(*resource)

source code 

Returns an iterator which gives each directory named 'resource' in the shared data search path. Information provided by earlier directories should take precedence over later ones.

Since: 0.28

load_first_data(*resource)

source code 

Returns the first result from load_data_paths, or None if there is nothing to load.

Returns: str | None

Since: 0.28

save_data_path(*resource)

source code 

Ensure $XDG_DATA_HOME/<resource>/ exists, and return its path. 'resource' should normally be the name of your application.

Returns: str

Variables Details

home

The value of $HOME (or '/' if not set). If we're running as root and $HOME isn't owned by root, then this will be root's home from /etc/passwd instead.
Value:
pwd.getpwuid(0).pw_dir or '/'

localAppData

Value:
shell.SHGetFolderPath(0, shellcon.CSIDL_LOCAL_APPDATA, 0, 0)

commonAppData

Value:
shell.SHGetFolderPath(0, shellcon.CSIDL_COMMON_APPDATA, 0, 0)

xdg_data_dirs

Value:
_get_path('XDG_DATA_HOME', 'XDG_DATA_DIRS', _default_paths ['DATA'])

xdg_cache_dirs

Value:
_get_path('XDG_CACHE_HOME', 'XDG_CACHE_DIRS', _default_paths ['CACHE']\
)

xdg_config_dirs

Value:
_get_path('XDG_CONFIG_HOME', 'XDG_CONFIG_DIRS', _default_paths ['CONFI\
G'])