App directories - unihan_etl._internal.app_dirs

AppDir wrapper for appdirs package.

Special features

This module offers several advantages over appdirs:

unihan_etl._internal.app_dirs.MISSING_DIR

A sentinel object to detect if a path is supplied or not.

class unihan_etl._internal.app_dirs.AppDirs(_app_dirs, user_data_dir=PosixPath('8751569391437'), site_data_dir=PosixPath('8751569391437'), user_config_dir=PosixPath('8751569391437'), site_config_dir=PosixPath('8751569391437'), user_cache_dir=PosixPath('8751569391437'), user_state_dir=PosixPath('8751569391437'), user_log_dir=PosixPath('8751569391437'))[source]

Bases: object

Wrap appdirs.AppDirs’s paths in typed pathlib.Path’s.

Retrieve directories as dataclass in pathlib.Path format:

>>> from appdirs import AppDirs as BaseAppDirs
>>> app_dirs = AppDirs(_app_dirs=BaseAppDirs())
>>> app_dirs.user_log_dir
PosixPath('.../log')

Override directories:

>>> app_dirs = AppDirs(_app_dirs=BaseAppDirs(), user_log_dir='/var/log/myapp')
>>> app_dirs.user_log_dir
PosixPath('/var/log/myapp')

Replace environment variables via os.expandfars:

>>> import os
>>> os.environ['my_cache_var'] = '/var/cache/'
>>> app_dirs = AppDirs(
...     _app_dirs=BaseAppDirs(), user_cache_dir='${my_cache_var}/myapp'
... )
>>> app_dirs.user_cache_dir
PosixPath('/var/cache/myapp')

Support for XDG environmental variables:

>>> import os
>>> os.environ['XDG_CACHE_HOME'] = '/var/cache/'
>>> app_dirs = AppDirs(_app_dirs=BaseAppDirs())
>>> app_dirs.user_cache_dir
PosixPath('/var/cache')
Parameters:
  • _app_dirs (dataclasses.InitVar['BaseAppDirs'])

  • user_data_dir (Path)

  • site_data_dir (Path)

  • user_config_dir (Path)

  • site_config_dir (Path)

  • user_cache_dir (Path)

  • user_state_dir (Path)

  • user_log_dir (Path)

_app_dirs: InitVar
user_data_dir: Path
site_data_dir: Path
user_config_dir: Path
site_config_dir: Path
user_cache_dir: Path
user_state_dir: Path
user_log_dir: Path