Package x2go :: Module inifiles :: Class X2GoIniFile
[frames] | no frames]

Class X2GoIniFile

source code

object --+
         |
        X2GoIniFile

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.

Instance Methods
 
__init__(self, config_files, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
load(self)
R(e-r)ead configuration file(s).
source code
 
__repr__(self)
repr(x)
source code
 
update_value(self, section, key, value)
Change a value for a given section and key.
source code
bool
write(self)
Write the ini file modifications (SafeConfigParser object) from RAM to disk.
source code
class
get_type(self, section, key)
Retrieve a value type for a given section and key.
source code
class
get_value(self, section, key, key_type=None)
Retrieve a value for a given section and key.
source code
class
get(self, section, key, key_type=None)
Retrieve a value for a given section and key.
source code
class
__call__(self, section, key, key_type=None)
Retrieve a value for a given section and key.
source code
 
printable_config_file(self)
Returns a printable configuration file as a multi-line string.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, config_files, defaults=None, logger=None, loglevel=log.loglevel_DEFAULT)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • config_files (list) - a list of configuration file names (e.g. a global filename and a user's home directory filename)
  • defaults (dict) - a cascaded Python dicitionary structure with ini file defaults (to override Python X2Go's hard coded defaults in defaults
  • logger (X2GoLogger instance) - you can pass an X2GoLogger object to the X2GoIniFile constructor
  • loglevel (int) - if no X2GoLogger object has been supplied a new one will be constructed with the given loglevel
Overrides: object.__init__

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

update_value(self, section, key, value)

source code 

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(self)

source code 

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: bool
True if the user config file has been successfully written, False otherwise.

get_type(self, section, key)

source code 

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: class
a Python variable type

get_value(self, section, key, key_type=None)

source code 

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
Returns: class
the value for the given section and key

get(self, section, key, key_type=None)

source code 

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
Returns: class
the value for the given section and key

__call__(self, section, key, key_type=None)
(Call operator)

source code 

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
Returns: class
the value for the given section and key

printable_config_file(self)

source code 

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

Decorators:
  • @property