summaryrefslogtreecommitdiff
path: root/migrate/versioning/cfgparse.py
blob: 8f1ccf9fa563b0eb3fe64f1ac6503d59db1e3172 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
   Configuration parser module.
"""

from six.moves.configparser import ConfigParser

from migrate.versioning.config import *
from migrate.versioning import pathed


class Parser(ConfigParser):
    """A project configuration file."""

    def to_dict(self, sections=None):
        """It's easier to access config values like dictionaries"""
        return self._sections


class Config(pathed.Pathed, Parser):
    """Configuration class."""

    def __init__(self, path, *p, **k):
        """Confirm the config file exists; read it."""
        self.require_found(path)
        pathed.Pathed.__init__(self, path)
        Parser.__init__(self, *p, **k)
        self.read(path)