Salome HOME
CCAR : remplacement separateur New24.gif par Sep.gif
[tools/eficas.git] / Exemples / ex3 / parse.py
1
2 from ConfigParser import ConfigParser
3
4 class MyConfParser(ConfigParser):
5    def getdicttext(self):
6       s='{'
7       for section in self.sections():
8          s=s+ "'" + section + "' : {"
9          options=self.options(section)
10          for option in options:
11             value=self.get(section,option)
12             s=s+"'%s' : %s," % (option, value)
13          s=s+"}, "
14       s=s+"}"
15       return s
16
17    def getdict(self):
18       return eval(self.getdicttext())
19          
20 if __name__ == '__main__':
21    p=MyConfParser()
22    p.read("toto.ini")
23    print p.getdicttext()
24    print p.getdict()