| Conditions | 4 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import os |
||
| 37 | def dbconfig(filename=basedir+'database.ini', section='postgresql'): |
||
| 38 | #create a parser |
||
| 39 | parser = ConfigParser() |
||
| 40 | #read config file |
||
| 41 | parser.read(filename) |
||
| 42 | |||
| 43 | #get section, default to postgres |
||
| 44 | db={} |
||
| 45 | if parser.has_section(section): |
||
| 46 | params = parser.items(section) |
||
| 47 | for param in params: |
||
| 48 | db[param[0]] = param[1] |
||
| 49 | else: |
||
| 50 | raise Exception('section {0} not found in the {1} file'.format(section,filename)) |
||
| 51 | return db |