How to use the everett.manager.get_key_from_envs 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_get_key_from_envs():
    assert get_key_from_envs({"K": "v"}, "K") == "v"
    assert get_key_from_envs([{"K": "v"}, {"L": "w"}], "L") == "w"
    assert get_key_from_envs({"K": "v"}, "Q") is NO_VALUE
    # first match wins
    envs = [{"K": "v"}, {"L": "w"}, {"K": "z"}]
    assert get_key_from_envs(envs, "K") == "v"
    # works with reversed iterator
    envs = reversed([{"L": "v"}, {"L": "w"}])
    assert get_key_from_envs(envs, "L") == "w"
    # works with os.environ
    os.environ["DUDE_ABIDES"] = "yeah, man"
    assert get_key_from_envs(os.environ, "DUDE_ABIDES") == "yeah, man"
github willkg / everett / tests / test_manager.py View on Github external
def test_get_key_from_envs():
    assert get_key_from_envs({"K": "v"}, "K") == "v"
    assert get_key_from_envs([{"K": "v"}, {"L": "w"}], "L") == "w"
    assert get_key_from_envs({"K": "v"}, "Q") is NO_VALUE
    # first match wins
    envs = [{"K": "v"}, {"L": "w"}, {"K": "z"}]
    assert get_key_from_envs(envs, "K") == "v"
    # works with reversed iterator
    envs = reversed([{"L": "v"}, {"L": "w"}])
    assert get_key_from_envs(envs, "L") == "w"
    # works with os.environ
    os.environ["DUDE_ABIDES"] = "yeah, man"
    assert get_key_from_envs(os.environ, "DUDE_ABIDES") == "yeah, man"
github willkg / everett / tests / test_manager.py View on Github external
def test_get_key_from_envs():
    assert get_key_from_envs({"K": "v"}, "K") == "v"
    assert get_key_from_envs([{"K": "v"}, {"L": "w"}], "L") == "w"
    assert get_key_from_envs({"K": "v"}, "Q") is NO_VALUE
    # first match wins
    envs = [{"K": "v"}, {"L": "w"}, {"K": "z"}]
    assert get_key_from_envs(envs, "K") == "v"
    # works with reversed iterator
    envs = reversed([{"L": "v"}, {"L": "w"}])
    assert get_key_from_envs(envs, "L") == "w"
    # works with os.environ
    os.environ["DUDE_ABIDES"] = "yeah, man"
    assert get_key_from_envs(os.environ, "DUDE_ABIDES") == "yeah, man"
github willkg / everett / tests / test_manager.py View on Github external
def test_get_key_from_envs():
    assert get_key_from_envs({"K": "v"}, "K") == "v"
    assert get_key_from_envs([{"K": "v"}, {"L": "w"}], "L") == "w"
    assert get_key_from_envs({"K": "v"}, "Q") is NO_VALUE
    # first match wins
    envs = [{"K": "v"}, {"L": "w"}, {"K": "z"}]
    assert get_key_from_envs(envs, "K") == "v"
    # works with reversed iterator
    envs = reversed([{"L": "v"}, {"L": "w"}])
    assert get_key_from_envs(envs, "L") == "w"
    # works with os.environ
    os.environ["DUDE_ABIDES"] = "yeah, man"
    assert get_key_from_envs(os.environ, "DUDE_ABIDES") == "yeah, man"
github willkg / everett / tests / test_manager.py View on Github external
def test_get_key_from_envs():
    assert get_key_from_envs({"K": "v"}, "K") == "v"
    assert get_key_from_envs([{"K": "v"}, {"L": "w"}], "L") == "w"
    assert get_key_from_envs({"K": "v"}, "Q") is NO_VALUE
    # first match wins
    envs = [{"K": "v"}, {"L": "w"}, {"K": "z"}]
    assert get_key_from_envs(envs, "K") == "v"
    # works with reversed iterator
    envs = reversed([{"L": "v"}, {"L": "w"}])
    assert get_key_from_envs(envs, "L") == "w"
    # works with os.environ
    os.environ["DUDE_ABIDES"] = "yeah, man"
    assert get_key_from_envs(os.environ, "DUDE_ABIDES") == "yeah, man"
github willkg / everett / tests / test_manager.py View on Github external
def test_get_key_from_envs():
    assert get_key_from_envs({"K": "v"}, "K") == "v"
    assert get_key_from_envs([{"K": "v"}, {"L": "w"}], "L") == "w"
    assert get_key_from_envs({"K": "v"}, "Q") is NO_VALUE
    # first match wins
    envs = [{"K": "v"}, {"L": "w"}, {"K": "z"}]
    assert get_key_from_envs(envs, "K") == "v"
    # works with reversed iterator
    envs = reversed([{"L": "v"}, {"L": "w"}])
    assert get_key_from_envs(envs, "L") == "w"
    # works with os.environ
    os.environ["DUDE_ABIDES"] = "yeah, man"
    assert get_key_from_envs(os.environ, "DUDE_ABIDES") == "yeah, man"
github willkg / everett / everett / ext / yamlfile.py View on Github external
def get(self, key, namespace=None):
        """Retrieve value for key."""
        if not self.path:
            return NO_VALUE

        logger.debug("Searching %r for key: %s, namepsace: %s", self, key, namespace)
        full_key = generate_uppercase_key(key, namespace)
        return get_key_from_envs(self.cfg, full_key)
github willkg / everett / everett / ext / inifile.py View on Github external
def get(self, key, namespace=None):
        """Retrieve value for key."""
        if not self.path:
            return NO_VALUE

        # NOTE(willkg): The "main" section is considered the root mainspace.
        namespace = namespace or ["main"]
        logger.debug("Searching %r for key: %s, namespace: %s", self, key, namespace)
        full_key = generate_uppercase_key(key, namespace)
        return get_key_from_envs(self.cfg, full_key)