logsnarf.config module
Logsnarf configuration.
See configuration for details on how to configure logsnarf.
- class logsnarf.config.Config(resource_name=None, config_file=None)[source]
Bases:
Mapping
Class to contain configuration information for Logsnarf.
This class wraps loading of the configparser config file(s), initializing logging (from a logging.ini), and proxies some methods from xdg.BaseDirectory module for creating/opening config or data files in appropriate places.
It also provides a dict-like read-only interface to the config file, with a vague attempt at type casting through ConfigSection objects.
- Parameters:
- loadConfigPaths()[source]
Returns the configuration paths for the resource.
Returns an iterator which gives each directory named ‘logsnarf’ in the configuration search path. Information provided by earlier directories should take precedence over later ones, and the user-specific config dir comes first.
- loadLoggingConfig()[source]
Initializes logging.
The twisted PythonLoggingObserver is initialized, then the config paths are searched for a ${RESOURCE_NAME}/logging.ini, failing that, logging.basicConfig() is called with no arguments so that some sort of logging occurs.
- openDataFile(name, mode, *args, **kwargs)[source]
Opens a file in the user data directory, with the given mode.
- saveConfigPath(name='')[source]
Ensures the user save config path exists, and returns the path.
Optionally also provide a filename, to receive a full path to that file in the data directory.
Ensure
$XDG_CONFIG_HOME/logsnarf/
exists, and return its path. Use this when saving or updating application configuration.
- saveDataPath(name='')[source]
Ensures the user save data path exists, and returns the path to it.
Optionally also provide a filename, to receive a full path to that file in the data directory.
Ensure
$XDG_DATA_HOME/logsnarf/
exists, and return its path. Use this when saving or updating application data.
- class logsnarf.config.ConfigSection(name, cfg)[source]
Bases:
Mapping
Class representing a configparser section.
Provides a mapping interface that attempts to do some vaguely sane type casting. No attempt to be smart, cache results etc is done.
- Parameters:
name (str) – section name
cfg (configparser.ConfigParser) – configparser object