clapper.rc

Implements a global configuration system setup and readout.

Classes

UserDefaults(path[, logger])

Contains user defaults read from the user TOML configuration file.

class clapper.rc.UserDefaults(path, logger=None)[source]

Bases: MutableMapping

Contains user defaults read from the user TOML configuration file.

Upon intialisation, an instance of this class will read the user configuration file defined by the first argument. If the input file is specified as a relative path, then it is considered relative to the environment variable ${XDG_CONFIG_HOME}, or its default setting (which is operating system dependent, c.f. XDG defaults).

This object may be used (with limited functionality) like a dictionary. In this mode, objects of this class read and write values to the DEFAULT section. The len() method will also return the number of variables set at the DEFAULT section as well.

Parameters:
  • path (str | Path) – The path, absolute or relative, to the file containing the user defaults to read. If path is a relative path, then it is considered relative to the directory defined by the environment variable ${XDG_CONFIG_HOME} (read XDG defaults for details on the default location of this directory in the various operating systems). The tilde (~) character may be used to represent the user home, and is automatically expanded.

  • logger (Logger | None) – A logger to use for messaging operations. If not set, use this module’s logger.

path

The current path to the user defaults base file.

read()[source]

Read configuration file, replaces any internal values.

Return type:

None

write()[source]

Store any modifications done on the user configuration.

Return type:

None