Package Biskit :: Module SettingsParser :: Class SettingsParser
[hide private]
[frames] | no frames]

Class SettingsParser

source code


A config file parser on steroids -- performs the following tasks:
  • read a ini-style settings file
  • type-cast options (e.g. of the form int-some_name into int(some_name))
  • validate that all entries of section [PATHS] point to existing paths
  • absolutize all valid paths
  • validate that all entries of section [BINARIES] point to binaries


  • Instance Methods [hide private]
      __init__(self, ini)
    x.__init__(...) initializes x; see x.__class__.__doc__ for signature
      __validPath(self, v)
    Returns validated absolute Path @rtype : str
      __validBinary(self, v)
    Returns validated absolute path to existing binary @rtype : str
    type, str __type(self, option, default=str)
    Extract type from option name.
    Setting __process(self, option, value, section=Setting.NORMAL)
    Returns new setting
      __processSection(self, items, section=Setting.NORMAL, verbose=False)
    Returns {str: Setting}
    {str: Setting} parse(self, verbose=False)
    Returns dict of type-cast params contained in fini
      __repr__(self, tab='\t')
    repr(x)

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


    Properties [hide private]

    Inherited from object: __class__


    Method Details [hide private]

    __init__(self, ini)
    (Constructor)

    source code 

    x.__init__(...) initializes x; see x.__class__.__doc__ for signature
    Overrides: object.__init__
    (inherited documentation)

    __validPath(self, v)

    source code 
    Parameters:
    • v (str) - potential path name
    Returns:
    validated absolute Path @rtype : str
    Raises:

    __validBinary(self, v)

    source code 
    Parameters:
    • v (str) - potential binary path
    Returns:
    validated absolute path to existing binary @rtype : str
    Raises:

    __type(self, option, default=str)

    source code 

    Extract type from option name.
    Parameters:
    • option (str) - name of parameter
    • default (type) - default type [str]
    Returns: type, str
    type, stripped option name (e.g. 'int_var1' -> int, 'var1')
    Raises:
    • TypeError - if type cannot be interpreted

    __process(self, option, value, section=Setting.NORMAL)

    source code 
    Parameters:
    • option (str) - option name
    • value (str) - option value
    • section (str) - which section are we working on
    Returns: Setting
    new setting
    Raises:

    __processSection(self, items, section=Setting.NORMAL, verbose=False)

    source code 
    Parameters:
    • items ([ ( str, str ) ]) - section comming from ConfigParser
    • section (str) - which config section are we working on?
    Returns:
    {str: Setting}

    parse(self, verbose=False)

    source code 
    Parameters:
    • verbose (bool) - print warning messages via Biskit.EHandler
    Returns: {str: Setting}
    dict of type-cast params contained in fini
    Raises:
    • IOError - if the settings file does not exist
    • SettingsError - (InvalidFile, InvalidValue, InvalidType)

    __repr__(self, tab='\t')
    (Representation operator)

    source code 

    repr(x)
    Overrides: object.__repr__
    (inherited documentation)