ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/VHbb/python/BetterConfigParser.py
Revision: 1.2
Committed: Wed Jan 16 16:22:42 2013 UTC (12 years, 3 months ago) by peller
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Error occurred while calculating annotation data.
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

# Content
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