python-igraph manual

For using igraph from Python

   Home       Trees       Indices       Help   
Package igraph :: Module configuration :: Class Configuration
[hide private]

Class Configuration

source code

object --+
         |
        Configuration

Class representing igraph configuration details.

General ideas

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.

  • shells: the list of preferred Python shells to be used with the command-line igraph script. The shells in the list are tried one by one until any of them is found on the system. igraph functions are then imported into the main namespace of the shell and the shell is launched. Known shells and their respective class names to be used can be found in igraph.app.shell. Example: IPythonShell, ClassicPythonShell. This is the default, by the way.
  • verbose: whether igraph should talk more than really necessary. For instance, if set to True, some functions display progress bars.

Application settings

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

  • image_viewer: image viewer application. If set to an empty string, it will be determined automatically from the platform igraph runs on. On Mac OS X, it defaults to the Preview application. On Linux, it chooses a viewer from several well-known Linux viewers like gthumb, kuickview and so on (see the source code for the full list). On Windows, it defaults to the system's built-in image viewer.

Plotting settings

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

  • layout: default graph layout algorithm to be used.
  • mark_groups: whether to mark the clusters by polygons when plotting a clustering object.
  • palette: default palette to be used for converting integer numbers to colors. See colors.Palette for more information. Valid palette names are stored in colors.palettes.
  • wrap_labels: whether to try to wrap the labels of the vertices automatically if they don't fit within the vertex. Default: False.

Remote repository settings

These settings specify how igraph should access remote graph repositories. Currently only the Nexus repository is supported. All these settings are stored in section remote.

  • nexus.url: the root URL of the Nexus repository. Default: http://nexus.igraph.org.

Shell settings

These settings specify options for external environments in which igraph is embedded (e.g., IPython and its Qt console). These settings are stored in section shell.

  • ipython.inlining.Plot: whether to show instances of the Plot class inline in IPython's console if the console supports it. Default: True
Nested Classes [hide private]
  Types
Static class for the implementation of custom getter/setter functions for configuration keys
Instance Methods [hide private]
 
__init__(self, filename=None)
Creates a new configuration instance.
source code
 
_get(self, section, key)
Internal function that returns the value of a given key in a given section.
source code
 
__contains__(self, item)
Checks whether the given configuration item is set.
source code
 
__getitem__(self, item)
Returns the given configuration item.
source code
 
__setitem__(self, item, value)
Sets the given configuration item.
source code
 
__delitem__(self, item)
Deletes the given item from the configuration.
source code
 
has_key(self, item)
Checks if the configuration has a given key.
source code
 
load(self, stream=None)
Loads the configuration from the given file.
source code
 
save(self, stream=None)
Saves the configuration.
source code

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

Class Methods [hide private]
 
instance(cls)
Returns the single instance of the configuration object.
source code
Properties [hide private]
  filename
Returns the filename associated to the object.

Inherited from object: __class__

Method Details [hide private]

__init__(self, filename=None)
(Constructor)

source code 

Creates a new configuration instance.

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

__contains__(self, item)
(In operator)

source code 

Checks whether the given configuration item is set.

Parameters:
  • item - the configuration key to check.
Returns:
True if the key has an associated value, False otherwise.

__getitem__(self, item)
(Indexing operator)

source code 

Returns the given configuration item.

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

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

source code 

Sets the given configuration item.

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

__delitem__(self, item)
(Index deletion operator)

source code 

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.

has_key(self, item)

source code 

Checks if the configuration has a given key.

Parameters:
  • item - the key being sought

load(self, stream=None)

source code 

Loads the configuration from the given file.

Parameters:
  • stream - 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, stream=None)

source code 

Saves the configuration.

Parameters:
  • stream - 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.

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:
unreachable.filename(self) - Returns the filename associated to the object.

   Home       Trees       Indices       Help