示例#1
0
    def get(self, section, key):
        config = self.config

        if not config.has_section(section):
            raise KeyError("No section %s found." % section)

        if not config.has_option(section, key):
            raise KeyError("No key %s found." % key)

        value = auto_typecast(config.get(section, key))

        return value
示例#2
0
    def get(self, section, key):
        config = self.config

        if not section in config:
            raise KeyError("No section %s found." % section)

        if not key in config[section]:
            raise KeyError("No key %s found." % key)

        value = auto_typecast(config[section][key])

        return value
示例#3
0
def getenv(name,
           default=None,
           cast=True,
           prefix=PREFIX,
           seperator="_",
           raise_err=False):
    envvar = getenvvar(name, prefix=prefix, seperator=seperator)

    if not envvar in list(os.environ) and raise_err:
        raise KeyError("Environment Variable %s not found." % envvar)

    value = os.getenv(envvar, default)
    value = auto_typecast(value) if cast else value

    return value