Package atmopy :: Package talos :: Module config_stream :: Class ConfigStream
[show private | hide private]
[frames | no frames]

Class ConfigStream


Manages a configuration file. The ConfigStream class provides an interface to the Talos config file system, through calls to the extract_configuration program.
Method Summary
  __init__(self, file)
Boolean GetBool(self, element, section)
Returns the value (Boolean) of a given field.
datetime GetDateTime(self, element, section)
Returns the value (datetime) of a given field.
given by 'type' GetElement(self, element, section, type)
Returns the value of a given field.
float GetFloat(self, element, section)
Returns specified element value in given section, as float.
int GetInt(self, element, section)
Returns specified element value in given section, as integer
int (preferred) or float GetNum(self, element, section)
Returns the value (number: int or float) of a given field.
string GetOutput(self, command)
Calls external program extract_configuration (which must be in the PATH), and returns output of execution on success.
string GetString(self, element, section)
Returns the value (string) of a given field.
string ListAll(self)
Lists everything in config file.
string ListSectionLines(self, section)
Lists everything in specified section of config file.
string ListSections(self)
Lists all sections of config file.
datetime StringToDateTime(self, str)
Converts a string into a datetime object.

Method Details

GetBool(self, element, section='')

Returns the value (Boolean) of a given field.
Parameters:
element - The element (field) to be found in the configuration file.
           (type=string)
section - The section in which the element should be found, if any.
           (type=string)
Returns:
The value of the field in the configuration file.
           (type=Boolean)

GetDateTime(self, element, section='')

Returns the value (datetime) of a given field.
Parameters:
element - The element (field) to be found in the configuration file.
           (type=string)
section - The section in which the element should be found, if any.
           (type=string)
Returns:
The value of the field in the configuration file.
           (type=datetime)

Note: The field value should be in format YYYY, YYYYMM, YYYYMMDD, YYYYMMDDHH, YYYYMMDDHHMM or YYYYMMDDHHMMSS. Delimiters (any character except numbers) can be added around the month, the day, etc.

GetElement(self, element, section='', type='String')

Returns the value of a given field.
Parameters:
element - The element (field) to be found in the configuration file.
           (type=string)
section - The section in which the element should be found, if any.
           (type=string)
type - The type of the element to be returned. It could be: 'Int', 'IntList', 'IntSection', 'Bool', 'Float', 'FloatList', 'FloatSection', 'String', 'StringList', 'StringSection', 'Num', 'NumList' or 'NumSection'. 'Num' means 'Int' or 'Float'.
           (type=string)
Returns:
The value of the field in the configuration file.
           (type=given by 'type')

Warning: In case the output is a list, the section is not taken into account, which means that two lists against the same field name should not be introduced in the configuration file, even in two different sections.

GetFloat(self, element, section='')

Returns specified element value in given section, as float.
Parameters:
element - The element (field) to be found in the configuration file.
           (type=string)
section - The section in which the element should be found, if any.
           (type=string)
Returns:
The specified element value in given section, as float.
           (type=float)

GetInt(self, element, section='')

Returns specified element value in given section, as integer
Parameters:
element - The element (field) to be found in the configuration file.
           (type=string)
section - The section in which the element should be found, if any.
           (type=string)
Returns:
The specified element value in given section, as integer.
           (type=int)

GetNum(self, element, section='')

Returns the value (number: int or float) of a given field.
Parameters:
element - The element (field) to be found in the configuration file.
           (type=string)
section - The section in which the element should be found, if any.
           (type=string)
Returns:
The value of the field in the configuration file.
           (type=int (preferred) or float)

GetOutput(self, command)

Calls external program extract_configuration (which must be in the PATH), and returns output of execution on success. Raises exception on failure.
Parameters:
command - Options string to pass to extract_configuration program.
           (type=string)
Returns:
extract_configuration Output and error messages, or launch an exception if an error occured.
           (type=string)

GetString(self, element, section='')

Returns the value (string) of a given field.
Parameters:
element - The element (field) to be found in the configuration file.
           (type=string)
section - The section in which the element should be found, if any.
           (type=string)
Returns:
The value of the field in the configuration file.
           (type=string)

ListAll(self)

Lists everything in config file.
Returns:
String containing everything in config file.
           (type=string)

ListSectionLines(self, section)

Lists everything in specified section of config file.
Parameters:
section - Name of the section to list elements from.
           (type=string)
Returns:
String containing everything in given section of config file.
           (type=string)

ListSections(self)

Lists all sections of config file.
Returns:
String containing all sections of config file.
           (type=string)

StringToDateTime(self, str)

Converts a string into a datetime object.
Parameters:
str - String to be converted. It must be in format YYYY, YYYYMM, YYYYMMDD, YYYYMMDDHH, YYYYMMDDHHMM or YYYYMMDDHHMMSS. Delimiters (any character except numbers) can be added around the month, the day, etc.
           (type=string)
Returns:
The datetime object corresponding to 'str'.
           (type=datetime)

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