x2go.inifiles module

X2GoProcessIniFile - helper class for parsing .ini files

class x2go.inifiles.X2GoIniFile(config_files, defaults=None, logger=None, loglevel=56)[source]

Bases: object

Base class for processing the different ini files used by X2Go clients. Primarily used to standardize the content of the different X2Go client ini file (settings, printing, sessions, xconfig).

If entries are omitted in an ini file, they are filled with default values (as hard coded in Python X2Go), so the resulting objects always contain the same fields.

get(section, key, key_type=None)

Retrieve a value for a given section and key.

Parameters:
  • section (str) – the ini file section
  • key (str) – the ini file key in the given section
  • key_type – Python data type of the given key (Default value = None)
Returns:

the value for the given section and key

Return type:

class

get_type(section, key)[source]

Retrieve a value type for a given section and key. The returned value type is based on the default values dictionary.

Parameters:
  • section (str) – the ini file section
  • key (str) – the ini file key in the given section
Returns:

a Python variable type

Return type:

class

get_value(section, key, key_type=None)[source]

Retrieve a value for a given section and key.

Parameters:
  • section (str) – the ini file section
  • key (str) – the ini file key in the given section
  • key_type – Python data type of the given key (Default value = None)
Returns:

the value for the given section and key

Return type:

class

load()[source]

R(e-r)ead configuration file(s).

printable_config_file

Returns a printable configuration file as a multi-line string.

update_value(section, key, value)[source]

Change a value for a given section and key. This method does not have any effect on configuration files.

Parameters:
  • section (str) – the ini file section
  • key (str) – the ini file key in the given section
  • value (str, list, bool, ...) – the value for the given section and key
write()[source]

Write the ini file modifications (SafeConfigParser object) from RAM to disk.

For writing the first of the config_files specified on instance construction that is writable will be used.

Returns:True if the user config file has been successfully written, False otherwise.
Return type:bool