import collections

Setting = collections.namedtuple('Setting', 'key fallback')


class Settings(object):
    ENV = Setting(key='env', fallback='dev')
    APP = Setting(key='app', fallback='python')
    COLOR = Setting(key='color', fallback=False)

    def __init__(self, **kwargs):
        self._kw = kwargs

    def get_env(self):
        return self.get(self.ENV.key, self.ENV.fallback)

    def get_app(self):
        return self.get(self.APP.key, self.APP.fallback)

    def is_log_coloring_enabled(self):
        return self.get(self.COLOR.key, self.COLOR.fallback)

    def get(self, key, fallback=None):
        if callable(fallback):
            return self._kw.get(key, fallback())
        return self._kw.get(key, fallback)
