ec2control / ec2control / config.py

import ConfigParser

class Config(object):
    def __init__(self, config_file_name):
        self.config = ConfigParser.RawConfigParser()
        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))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.