How to use the dynaconf.loaders.yaml_loader.load function in dynaconf

To help you get started, weā€™ve selected a few dynaconf 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 rochacbruno / dynaconf / tests / test_yaml_loader.py View on Github external
def test_extra_yaml():
    """Test loading extra yaml file"""
    load(settings, filename=YAML)
    yaml = """
    example:
       helloexample: world
    """
    settings.set("YAML", yaml)
    settings.execute_loaders(env="EXAMPLE")
    assert settings.HELLOEXAMPLE == "world"
github rochacbruno / dynaconf / tests / test_yaml_loader.py View on Github external
def test_load_from_yaml():
    """Assert loads from YAML string"""
    load(settings, filename=YAML)
    assert settings.HOST == "prodserver.com"
    assert settings.PORT == 8080
    assert settings.ALIST == ["item1", "item2", 23]
    assert settings.SERVICE["url"] == "service.com"
    assert settings.SERVICE.url == "service.com"
    assert settings.SERVICE.port == 80
    assert settings.SERVICE.auth.password == "qwerty"
    assert settings.SERVICE.auth.test == 1234
    load(settings, filename=YAML, env="DEVELOPMENT")
    assert settings.HOST == "devserver.com"
    load(settings, filename=YAML)
    assert settings.HOST == "prodserver.com"
github rochacbruno / dynaconf / tests / test_yaml_loader.py View on Github external
def test_using_env(tmpdir):
    load(settings, filename=YAML)
    assert settings.HOST == "prodserver.com"

    tmpfile = tmpdir.mkdir("sub").join("test_using_env.yaml")
    tmpfile.write(YAML)
    with settings.using_env("DEVELOPMENT", filename=str(tmpfile)):
        assert settings.HOST == "devserver.com"
    assert settings.HOST == "prodserver.com"
github rochacbruno / dynaconf / tests / test_yaml_loader.py View on Github external
def test_empty_value():
    load(settings, filename="")
github rochacbruno / dynaconf / tests / test_yaml_loader.py View on Github external
def test_cleaner():
    load(settings, filename=YAML)
    assert settings.HOST == "prodserver.com"
    assert settings.PORT == 8080
    assert settings.ALIST == ["item1", "item2", 23]
    assert settings.SERVICE["url"] == "service.com"
    assert settings.SERVICE.url == "service.com"
    assert settings.SERVICE.port == 80
    assert settings.SERVICE.auth.password == "qwerty"
    assert settings.SERVICE.auth.test == 1234
    load(settings, filename=YAML, env="DEVELOPMENT")
    assert settings.HOST == "devserver.com"
    load(settings, filename=YAML)
    assert settings.HOST == "prodserver.com"

    settings.clean()
    with pytest.raises(AttributeError):
        assert settings.HOST == "prodserver.com"
github rochacbruno / dynaconf / tests / test_yaml_loader.py View on Github external
def test_no_filename_is_none():
    """Assert if passed no filename return is None"""
    assert load(settings) is None
github rochacbruno / dynaconf / tests / test_yaml_loader.py View on Github external
def test_load_single_key():
    """Test loading a single key"""
    yaml = """
    foo:
       bar: blaz
       zaz: naz
    """
    load(settings, filename=yaml, env="FOO", key="bar")
    assert settings.BAR == "blaz"
    assert settings.exists("BAR") is True
    assert settings.exists("ZAZ") is False
github rochacbruno / dynaconf / tests / test_yaml_loader.py View on Github external
def test_load_from_yaml():
    """Assert loads from YAML string"""
    load(settings, filename=YAML)
    assert settings.HOST == "prodserver.com"
    assert settings.PORT == 8080
    assert settings.ALIST == ["item1", "item2", 23]
    assert settings.SERVICE["url"] == "service.com"
    assert settings.SERVICE.url == "service.com"
    assert settings.SERVICE.port == 80
    assert settings.SERVICE.auth.password == "qwerty"
    assert settings.SERVICE.auth.test == 1234
    load(settings, filename=YAML, env="DEVELOPMENT")
    assert settings.HOST == "devserver.com"
    load(settings, filename=YAML)
    assert settings.HOST == "prodserver.com"
github rochacbruno / dynaconf / dynaconf / base.py View on Github external
def load_extra_yaml(self, env, silent, key):
        """This is deprecated, kept for compat

        .. deprecated:: 1.0.0
            Use multiple settings or INCLUDES_FOR_DYNACONF files instead.
        """
        if self.get("YAML") is not None:
            self.logger.warning(
                "The use of YAML var is deprecated, please define multiple "
                "filepaths instead: "
                "e.g: SETTINGS_FILE_FOR_DYNACONF = "
                "'settings.py,settings.yaml,settings.toml' or "
                "INCLUDES_FOR_DYNACONF=['path.toml', 'folder/*']"
            )
            yaml_loader.load(
                self,
                env=env,
                filename=self.find_file(self.get("YAML")),
                silent=silent,
                key=key,
            )
github quokkaproject / quokka / quokka / core / flask_dynaconf.py View on Github external
'JINJA_EXTENSIONS': app.jinja_env.extensions,
        'USE_LESS': False,
        # For some themes like bootstrap3 theme SITEURL must be ''
        'SITEURL': 'http://localhost:5000',
        'THEME_STATIC_DIR': 'theme',
        'FAVICON': 'favicon.ico',
        'FAVICON_IE': 'favicon.ico',
        'FAVICON_FILENAME': 'favicon.ico',
        # 'AVATAR': 'LOAD FROM UPLOADS',
        'NEWEST_FIRST_ARCHIVES': True
    })

    default_loader(app.theme_context)

    # load theme variables from YAML file
    yaml_loader.load(
        obj=app.theme_context,
        env='theme',
        filename=app.config.get('SETTINGS_MODULE_FOR_DYNACONF')
    )
    # overrride with QUOKKA_THEME_ prefixed env vars if exist
    env_loader.load_from_env(
        identifier='theme',
        key=None,
        env='quokka_theme',
        obj=app.theme_context,
        silent=True
    )

    # remove prefix for pelican-themes
    active = app.theme_context.get('ACTIVE', 'default')
    if active.startswith('pelican'):