Salome HOME
PN : pour prendre en compte le nouveau panneau : UNIQUE_ASSD_Panel_Reel
[tools/eficas.git] / Exemples / ex3 / parse.py
1 # -*- coding: utf-8 -*-
2
3 from ConfigParser import ConfigParser
4
5 class MyConfParser(ConfigParser):
6    def getdicttext(self):
7       s='{'
8       for section in self.sections():
9          s=s+ "'" + section + "' : {"
10          options=self.options(section)
11          for option in options:
12             value=self.get(section,option)
13             s=s+"'%s' : %s," % (option, value)
14          s=s+"}, "
15       s=s+"}"
16       return s
17
18    def getdict(self):
19       return eval(self.getdicttext())
20          
21 if __name__ == '__main__':
22    p=MyConfParser()
23    p.read("toto.ini")
24    print p.getdicttext()
25    print p.getdict()