userconfig

The guidata.userconfig module provides user configuration file (.ini file) management features based on ConfigParser (standard Python library).

It is the exact copy of the open-source package userconfig (MIT license).

19/12/2021: Removed Python 2 compatibility

guidata.userconfig.get_home_dir()[source]

Return user home directory

class guidata.userconfig.UserConfig(defaults)[source]

UserConfig class, based on ConfigParser name: name of the config options: dictionnary containing options or list of tuples (section_name, options)

Note that ‘get’ and ‘set’ arguments number and type differ from the overriden methods

check_default_values()[source]

Check the static options for forbidden data types

get_version(version='0.0.0')[source]

Return configuration (not application!) version

set_version(version='0.0.0', save=True)[source]

Set configuration (not application!) version

filename()[source]

Create a .ini filename located in user home directory

cleanup()[source]

Remove .ini file associated to config

set_as_defaults()[source]

Set defaults from the current config

reset_to_defaults(save=True, verbose=False)[source]

Reset config to Default values

get_default(section, option)[source]

Get Default value for a given (section, option)

Useful for type checking in ‘get’ method

get(section, option, default=<class 'guidata.userconfig.NoDefault'>, raw=None, **kwargs)[source]

Get an option section=None: attribute a default section name default: default value (if not specified, an exception will be raised if option doesn’t exist)

set_default(section, option, default_value)[source]

Set Default value for a given (section, option) -> called when a new (section, option) is set and no default exists

set(section, option, value, verbose=False, save=True)[source]

Set an option section=None: attribute a default section name

remove_section(section)[source]

Remove a file section.

remove_option(section, option)[source]

Remove an option.