aside.boilerplate.hooks module

Common code for user hooks.

public_attrs(obj: object)Dict[str, Any][source]

Extract all object attributes and values, which are considered public.

update_attrs(default: object, changed: type, name: str, verbose: bool)[source]

Propagate the user-defined attribute changes to the default object.

load_user_hooks(hook_dirs: Optional[List[PathLike]] = None)None[source]

Import and load the user hook files.

User hook files are searched in all the configuration directories, as specified by the XDG Base Directory Specification. The hook files (if present) are loaded in the following order:

  • aside/**.py in every directory specified in ${XDG_CONFIG_DIRS} in order of preference

  • ${XDG_CONFIG_HOME}/aside/**.py

The hook files in each directory are imported and evaluated in lexicographic order. To overwrite the application configuration and theme, the aside.config.register_config and aside.theme.register_theme hooks can be used.

make_default_class_def(cls: type)Tuple[str, str][source]

Generate default imports and register_* class definition for cls.

get_user_hook_dir(init_missing: bool = True, hook_dir: Optional[PathLike] = None)PathLike[source]

Get the default user hook directory.

Parameters
  • init_missing – Whether to initialize the user hook directory if it’s missing.

  • hook_dir – Use this directory instead of the ${XDG_CONFIG_HOME}.