Package ndg :: Package soap :: Package utils :: Module configfileparsers
[hide private]

Source Code for Module ndg.soap.utils.configfileparsers

 1  """Configuration file parsers specialisations 
 2   
 3  NERC DataGrid Project 
 4  """ 
 5  __author__ = "Philip Kershaw" 
 6  __date__ = "25/01/2010" 
 7  __copyright__ = "(C) 2010 Science and Technology Facilities Council" 
 8  __license__ = "BSD - see LICENSE file in top-level directory" 
 9  __contact__ = "Philip.Kershaw@stfc.ac.uk" 
10  __revision__ = '$Id: $' 
11  import re 
12  from ConfigParser import SafeConfigParser 
13   
14 -class CaseSensitiveConfigParser(SafeConfigParser):
15 ''' 16 Subclass the SafeConfigParser - to preserve the original string case of the 17 cfg section names - NB, the RawConfigParser default is to lowercase these 18 by default 19 '''
20 - def optionxform(self, optionstr):
21 '''@type optionstr: basestring 22 @param optionstr: config file option name 23 @return: option name with case preserved 24 @rtype: basestring 25 ''' 26 return optionstr
27
28 -class WithGetListConfigParser(CaseSensitiveConfigParser):
29 LIST_STRING_PAT = re.compile(',\s*') 30
31 - def getlist(self, section, option):
32 val = self.get(section, option) 33 return WithGetListConfigParser.LIST_STRING_PAT.split(val)
34