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).

guidata.userconfig.get_home_dir()[source]

Return user home directory

guidata.userconfig.encode_to_utf8(x)[source]

Encode unicode string in UTF-8 – but only with Python 2

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 at 0x0000000003D11948>, **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