Source

ec2control / ec2control / config.py

import ConfigParser

class Config(object):
    def __init__(self, config_file_name):
        self.config = ConfigParser.ConfigParser()
        self.config.read([config_file_name])

    def _split_name(self, name):
        if "." in name:
            return name.split(".", 1)
        else:
            return "ec2control", name

    def __getitem__(self, name):
        section, key = self._split_name(name)
        return self.config.get(section, key)

    def get(self, name, default=None):
        section, key = self._split_name(name)
        if self.config.has_option(section, key):
            return self.config.get(section, key)
        else:
            return default

    def has_section(self, sectionname):
        return self.config.has_section(sectionname)

    def section_dict(self, section):
        return dict(self.config.items(section))