[3] | 1 | """ |
---|
| 2 | Configuration parser module. |
---|
| 3 | """ |
---|
| 4 | |
---|
| 5 | from ConfigParser import ConfigParser |
---|
| 6 | |
---|
| 7 | from migrate.versioning.base import * |
---|
| 8 | from migrate.versioning import pathed |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | class Parser(ConfigParser): |
---|
| 12 | """A project configuration file.""" |
---|
| 13 | |
---|
| 14 | def to_dict(self, sections=None): |
---|
| 15 | """It's easier to access config values like dictionaries""" |
---|
| 16 | return self._sections |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | class Config(pathed.Pathed, Parser): |
---|
| 20 | """Configuration class.""" |
---|
| 21 | |
---|
| 22 | def __init__(self, path, *p, **k): |
---|
| 23 | """Confirm the config file exists; read it.""" |
---|
| 24 | self.require_found(path) |
---|
| 25 | pathed.Pathed.__init__(self, path) |
---|
| 26 | Parser.__init__(self, *p, **k) |
---|
| 27 | self.read(path) |
---|