ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/myutils/BetterConfigParser.py
Revision: 1.1
Committed: Wed Jan 16 16:35:40 2013 UTC (12 years, 3 months ago) by peller
Content type: text/x-python
Branch: MAIN
CVS Tags: lhcp_UnblindFix, hcp_Unblind, lhcp_11April, LHCP_PreAppFixAfterFreeze, LHCP_PreAppFreeze, workingVersionAfterHCP, HEAD
Log Message:
reorganized the whole repository. Macros im myutils, config files in subdirectories. Config file split in parts. Path config file restructured. Moved all path options to the path config. Changed the code accordingly.

File Contents

# User Rev Content
1 peller 1.1 import re,ConfigParser
2    
3     class BetterConfigParser(ConfigParser.SafeConfigParser):
4    
5     def get(self, section, option):
6     result = ConfigParser.SafeConfigParser.get(self, section, option, raw=True)
7     result = self.__replaceSectionwideTemplates(result)
8     return result
9    
10     def optionxform(self, optionstr):
11     '''
12     enable case sensitive options in .ini files
13     '''
14     return optionstr
15    
16     def __replaceSectionwideTemplates(self, data):
17     '''
18     replace <section|option> with get(section,option) recursivly
19     '''
20     result = data
21     findExpression = re.compile("((.*)\<!(.*)\|(.*)\!>(.*))*")
22     groups = findExpression.search(data).groups()
23     if not groups == (None, None, None, None, None): # expression not matched
24     result = self.__replaceSectionwideTemplates(groups[1])
25     result += self.get(groups[2], groups[3])
26     result += self.__replaceSectionwideTemplates(groups[4])
27     return result