maestral.config.user
This module provides user configuration file management and is mostly copied from the config module of the Spyder IDE.
- class maestral.config.user.DefaultsConfig(path)[source]
Bases:
configparser.ConfigParser
Class used to save defaults to a file and as base class for UserConfig.
- Parameters
path (str) –
- Return type
None
- class maestral.config.user.UserConfig(path, defaults=None, load=True, version=<Version('0.0.0')>, backup=False, remove_obsolete=False)[source]
Bases:
maestral.config.user.DefaultsConfig
UserConfig class, based on ConfigParser. This class is safe to use from different threads but must not be used from different processes!
- Parameters
path (str) – Configuration file will be saved to this path.
defaults (Optional[Dict[str, Dict[str, Any]]]) – Dictionary containing options.
version (packaging.version.Version) – Version of the configuration file.
backup (bool) – Whether to create a backup on version changes and on initial setup.
remove_obsolete (bool) – If True, values that were removed from the configuration on version change, are removed from the saved configuration file.
load (bool) –
- Return type
None
Note
The
get
andset
arguments number and type differ from the reimplemented methods.- DEFAULT_SECTION_NAME = 'main'
- remove_deprecated_options()[source]
Remove options which are present in the file but not in defaults.
- Return type
None
- apply_configuration_patches(old_version)[source]
Apply any patch to configuration values on version changes.
To be reimplemented if patches to configuration values are needed.
- Parameters
old_version (packaging.version.Version) – Old config version to patch.
- Return type
None
- get_version()[source]
Get the current config version.
- Returns
Configuration (not application!) version.
- Return type
packaging.version.Version
- set_version(version, save=True)[source]
Set configuration (not application!) version.
- Parameters
version (packaging.version.Version) – New version to set.
save (bool) – Whether to save changes to drive.
- Return type
None
- get_default(section, option)[source]
Get default value for a given
section
andoption
.This is useful for type checking in get method.
- get(section, option, default=<class 'maestral.config.user.NoDefault'>)[source]
Get an option.
- Parameters
- Returns
Config value.
- Raises
cp.NoSectionError – if the section does not exist.
cp.NoOptionError – if the option does not exist and no default is given.
- Return type
- set_default(section, option, default_value)[source]
Set Default value for a given section, option.
If the section or option does not exist, it will be created.
- set(section, option, value, save=True)[source]
Set an
option` on a given ``section
.If section is None, the
option
is added to the default section.