xdg_basedir

Constants

jnrbase.xdg_basedir.ALLOW_DARWIN: bool = True

Allow macOS directory structure

Functions

jnrbase.xdg_basedir.user_cache(__pkg: str) → pathlib.Path

Return a cache location honouring XDG_CACHE_HOME.

XDG_CACHE_HOME

See XDG base directory spec.

Parameters

__pkg (str) – Package name

Return type

Path

jnrbase.xdg_basedir.user_config(__pkg: str) → pathlib.Path

Return a config location honouring XDG_CONFIG_HOME.

XDG_CONFIG_HOME

See XDG base directory spec.

Parameters

__pkg (str) – Package name

Return type

Path

jnrbase.xdg_basedir.user_data(__pkg: str) → pathlib.Path

Return a data location honouring XDG_DATA_HOME.

XDG_DATA_HOME

See XDG base directory spec.

Parameters

__pkg (str) – Package name

Return type

Path

jnrbase.xdg_basedir.get_configs(__pkg, __name='config')[source]

Return all configs for given package.

Parameters
  • __pkg (str) – Package name

  • __name (str) – Configuration file name

Return type

List[Path]

jnrbase.xdg_basedir.get_data(__pkg, __name)[source]

Return top-most data file for given package.

Parameters
  • __pkg (str) – Package name

  • __name (str) – Data file name

Return type

Path

jnrbase.xdg_basedir.get_data_dirs(__pkg)[source]

Return all data directories for given package.

Parameters

__pkg (str) – Package name

Return type

List[Path]

Examples

 >>> user_cache('rdial')
 '/home/jay/.cache/rdial'
 >>> user_config('awesome')
 '/home/jay/.config/awesome'
 >>> user_data('gnupg')
 '/home/jay/.local/share/gnupg'

 >>> get_configs('taskwarrior', 'uda.rc')
 ['/home/jay/.config/taskwarrior/uda.rc']
 >>> get_data('git_certs', 'github.com.pem')
 '/home/jay/.local/share/git_certs/github.com.pem'
 >>> get_data('awesome', 'icons/awesome.svg')
 '/usr/share/awesome/icons/awesome.svg'