How to use the everett.manager.ConfigManager function in everett

To help you get started, we’ve selected a few everett examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github willkg / everett / tests / test_manager.py View on Github external
def test_default_must_be_string():
    config = ConfigManager([])

    with pytest.raises(ConfigurationError):
        assert config("DOESNOTEXIST", default=True)
github willkg / everett / tests / test_component.py View on Github external
def test_with_options():
    """Verify .with_options() restricts configuration"""
    config = ConfigManager(
        [ConfigDictEnv({"FOO_BAR": "a", "FOO_BAZ": "b", "BAR": "c", "BAZ": "d"})]
    )

    class SomeComponent(RequiredConfigMixin):
        required_config = ConfigOptions()
        required_config.add_option("baz", default="", doc="some help here", parser=str)

        def __init__(self, config):
            self.config = config.with_options(self)

    # Create the component with regular config
    comp = SomeComponent(config)
    assert comp.config("baz") == "d"
    with pytest.raises(ConfigurationError):
        # This is not a valid option for this component
        comp.config("bar")
github azavea / raster-vision / rastervision / rv_config.py View on Github external
profile = os.environ.get('RV_PROFILE')
            else:
                profile = RVConfig.DEFAULT_PROFILE

        if config_overrides is None:
            config_overrides = {}

        if rv_home is None:
            home = os.path.expanduser('~')
            rv_home = os.path.join(home, '.rastervision')
        self.rv_home = rv_home

        config_file_locations = self._discover_config_file_locations(profile)

        help_doc = ('Check https://docs.rastervision.io/ for docs.')
        self.config = ConfigManager(
            # Specify one or more configuration environments in
            # the order they should be checked
            [
                # Allow overrides
                ConfigDictEnv(config_overrides),

                # Looks in OS environment first
                ConfigOSEnv(),

                # Look for an .env file
                ConfigEnvFileEnv('.env'),

                # Looks in INI files in order specified
                ConfigIniEnv(config_file_locations),
            ],
github willkg / everett / docs / code / configuration_doc.py View on Github external
def main():
    config = ConfigManager(
        environments=[ConfigOSEnv()],
        doc='For configuration help, see https://example.com/configuration'
    )

    debug_mode = config(
        'debug', default='false', parser=bool,
        doc='True to put the app in debug mode. Don\'t use this in production!'
    )

    if debug_mode:
        print('Debug mode is on!')
    else:
        print('Debug mode off.')
github mozilla-iam / cis / python-modules / cis_processor / cis_processor / common.py View on Github external
def get_config():
    return ConfigManager(
        [ConfigIniEnv([os.environ.get("CIS_CONFIG_INI"), "~/.mozilla-cis.ini", "/etc/mozilla-cis.ini"]), ConfigOSEnv()]
    )
github mozilla-iam / cis / python-modules / cis_fake_well_known / cis_fake_well_known / common.py View on Github external
def get_config():
    return ConfigManager(
        [
            ConfigIniEnv([
                os.environ.get('CIS_CONFIG_INI'),
                '~/.mozilla-cis.ini',
                '/etc/mozilla-cis.ini'
            ]),
            ConfigOSEnv()
        ]
github mozilla-iam / cis / python-modules / cis_profile / cis_profile / common.py View on Github external
def get_config():
    return ConfigManager(
        [ConfigIniEnv([os.environ.get("CIS_CONFIG_INI"), "~/.mozilla-cis.ini", "/etc/mozilla-cis.ini"]), ConfigOSEnv()]
    )