Package atmopy :: Package talos :: Module config :: Class Config
[show private | hide private]
[frames | no frames]

Class Config


Instances of Config store a complete configuration extracted from a configuration file.
Method Summary
  __init__(self, filename, additional_content, new_content, show_error)
Config constructor.
  SetAttribute(self, x)
Sets an attribute based on its value in the configuration file.
  SetMetaAttributes(self)
Adds meta-attributes based on the primary attributes.

Method Details

__init__(self, filename, additional_content=[], new_content=[], show_error=False)
(Constructor)

Config constructor. It reads a set of attributes in a configuration file.
Parameters:
filename - The name of the configuration file.
           (type=string)
additional_content - Description of attributes (in addition to the default attributes) read in the configuration file. There are three or four elements in each tuple:
  1. the field name or section name (in case a whole section is put in the attribute), to be read in the configuration file;
  2. the section name (in which the field lies), discarded in case a whole section is read;
  3. the name of the attribute, optional (default: the field name);
  4. the type of the attribute: 'Int', 'IntList', 'IntSection', 'Bool', 'Float', 'FloatList', 'FloatSection', 'String', 'StringList, 'StringSection', 'Num, 'NumList' or 'NumSection', where 'Num' means 'Int' or 'Float', and 'Section' means that a whole section is read and returned in a list made of the section lines.

           (type=list of tuples of strings)
new_content - Description of all attributes. It overwrites the default attributes.
           (type=list of tuples of strings)
show_error - True if an exception may be launched when an error occurs, False otherwise.
           (type=Boolean)

SetAttribute(self, x)

Sets an attribute based on its value in the configuration file. If the corresponding field does not appear in the configuration files, the attribute is not created.
Parameters:
x - Each element of x contains three or four elements:
  1. the field name or section name (in case a whole section is put in the attribute), to be read in the configuration file;
  2. the section name (in which the field lies), discarded in case a whole section is read;
  3. the name of the attribute, optional (default: the field name);
  4. the type of the attribute: 'Int', 'IntList', 'IntSection', 'Bool', 'Float', 'FloatList', 'FloatSection', 'String', 'StringList, 'StringSection', 'Num, 'NumList' or 'NumSection', where 'Num' means 'Int' or 'Float', and 'Section' means that a whole section is read and returned in a list made of the section lines.

           (type=list of lists of strings)

SetMetaAttributes(self)

Adds meta-attributes based on the primary attributes. The meta-attributes are: origin = (t_min, y_min, x_min); Delta = (Delta_t, Delta_y, Delta_x); shape = (Nt, Ny, Nx).

Note: A meta-attribute is not created in case one of its primary attribute is missing. But no exception is raised.


Generated by Epydoc 2.1 on Tue May 19 10:37:13 2009 http://epydoc.sf.net