Package igraph :: Module configuration :: Class Configuration
[hide private]
[frames] | no frames]

Class Configuration

object --+
         |
        Configuration

Class representing igraph configuration details.

General things

The configuration of igraph is stored in the form of name-value pairs. This object provides an interface to the configuration data using the syntax known from dict:

>>> c=Configuration()
>>> c["general.verbose"] = True
>>> print c["general.verbose"]
True

Configuration keys are organized into sections, and the name to be used for a given key is always in the form section.keyname, like general.verbose in the example above. In that case, general is the name of the configuration section, and verbose is the name of the key. If the name of the section is omitted, it defaults to general, so general.verbose can be referred to as verbose:

>>> c=Configuration()
>>> c["verbose"] = True
>>> print c["general.verbose"]
True

User-level configuration is stored in ~/.igraphrc per default on Linux and Mac OS X systems, or in C:\Documents and Settings\username\.igraphrc on Windows systems. However, this configuration is read only when igraph is launched through its shell interface defined in igraph.app.shell. This behaviour might change before version 1.0.

Known configuration keys

The known configuration keys are presented below, sorted by section. When referring to them in program code, don't forget to add the section name, expect in the case of section general.

General settings

These settings are all stored in section general.

Application settings

These settings specify the external applications that are possibly used by igraph. They are all stored in section apps.

Plotting settings

These settings specify the default values used by plotting functions. They are all stored in section plotting.

Nested Classes [hide private]
  Types
Static class for the implementation of custom getter/setter functions for configuration keys
Instance Methods [hide private]
 
__delitem__(self, item)
Deletes the given item from the configuration.
 
__getitem__(self, item)
Returns the given configuration item.
 
__init__(self, filename=None)
Creates a new configuration instance.
 
__setitem__(self, item, value)
Sets the given configuration item.
 
_get_filename(self)
Returns the filename associated to the object.
 
has_key(self, item)
Checks if the configuration has a given key.
 
load(self, fp=None)
Loads the configuration from the given file.
 
save(self, fp=None)
Saves the configuration.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Static Methods [hide private]
 
_item_to_section_key(item)
Converts an item description to a section-key pair.
Class Variables [hide private]
  _definitions = {'apps.image_viewer': {'default': 'open'}, 'gen...
  _sections = ('general', 'apps', 'plotting')
  _types = {'boolean': {'getter': <unbound method SafeConfigPars...
Properties [hide private]
  filename
Returns the filename associated to the object.

Inherited from object: __class__

Method Details [hide private]

__delitem__(self, item)
(Index deletion operator)

 

Deletes the given item from the configuration.

If the item has a default value, the default value is written back instead of the current value. Without a default value, the item is really deleted.

__getitem__(self, item)
(Indexing operator)

 

Returns the given configuration item.

Parameters:
  • item - the configuration key to retrieve.
Returns:
the configuration value

__init__(self, filename=None)
(Constructor)

 

Creates a new configuration instance.

Parameters:
  • filename - file or file pointer to be read. Can be omitted.
Overrides: object.__init__

__setitem__(self, item, value)
(Index assignment operator)

 

Sets the given configuration item.

Parameters:
  • item - the configuration key to set
  • value - the new value of the configuration key

_get_filename(self)

 

Returns the filename associated to the object.

It is usually the name of the configuration file that was used when creating the object. Configuration.load always overwrites it with the filename given to it. If None, the configuration was either created from scratch or it was updated from a stream without name information.

_item_to_section_key(item)
Static Method

 

Converts an item description to a section-key pair.

Parameters:
  • item - the item to be converted
Returns:
if item contains a period (.), it is splitted into two parts at the first period, then the two parts are returned, so the part before the period is the section. If item does not contain a period, the section is assumed to be general, and the second part of the returned pair contains item unchanged

has_key(self, item)

 

Checks if the configuration has a given key.

Parameters:
  • item - the key being sought

load(self, fp=None)

 

Loads the configuration from the given file.

Parameters:
  • fp - name of a file or a file object. The configuration will be loaded from here. Can be omitted, in this case, the user-level configuration is loaded.

save(self, fp=None)

 

Saves the configuration.

Parameters:
  • fp - name of a file or a file object. The configuration will be saved there. Can be omitted, in this case, the user-level configuration file will be overwritten.

Class Variable Details [hide private]

_definitions

Value:
{'apps.image_viewer': {'default': 'open'},
 'general.shells': {'default': 'IPythonShell,ClassicPythonShell'},
 'general.verbose': {'default': True, 'type': 'boolean'},
 'plotting.layout': {'default': 'random'},
 'plotting.palette': {'default': 'gray'}}

_types

Value:
{'boolean': {'getter': <unbound method SafeConfigParser.getboolean>,
             'setter': <function setboolean at 0x26c7b0>}}

Property Details [hide private]

filename

Returns the filename associated to the object.

It is usually the name of the configuration file that was used when creating the object. Configuration.load always overwrites it with the filename given to it. If None, the configuration was either created from scratch or it was updated from a stream without name information.

Get Method:
_get_filename(self) - Returns the filename associated to the object.