How to use the everett.NO_VALUE 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 / ext / test_inifile.py View on Github external
def test_multiple_files(self, datadir):
        ini_filename = os.path.join(datadir, "config_test.ini")
        ini_filename_original = os.path.join(datadir, "config_test_original.ini")
        cie = ConfigIniEnv([ini_filename, ini_filename_original])
        # Only the first found file is loaded, so foo_original does not exist
        assert cie.get("foo_original") == NO_VALUE
        cie = ConfigIniEnv([ini_filename_original])
        # ... but it is there if only the original is loaded (safety check)
        assert cie.get("foo_original") == "original"
github mozilla-iam / sso-dashboard / dashboard / __init__.py View on Github external
try:
            if len(namespace) > 0:
                secret = getSecret(
                    name="{}.{}".format(namespace[0], key),
                    context={"app": "sso-dashboard"},
                    region="us-east-1",
                )
            else:
                secret = None
        except ItemNotFound:
            secret = None

        if secret is not None:
            return secret

        return NO_VALUE
github willkg / everett / everett / manager.py View on Github external
def __call__(
        self,
        key,
        namespace=None,
        default=NO_VALUE,
        alternate_keys=NO_VALUE,
        doc="",
        parser=str,
        raise_error=True,
        raw_value=False,
    ):
        """Return a config value bound to a component's options.

        :arg key: the key to look up

        :arg namespace: the namespace for the key--different environments
            use this differently

        :arg default: the default value (if any); this must be a string that is
            parseable by the specified parser

        :arg alternate_keys: the list of alternate keys to look up;
github willkg / everett / everett / manager.py View on Github external
def get_key_from_envs(envs, key):
    """Return the value of a key from the given dict respecting namespaces.

    Data can also be a list of data dicts.

    """
    # if it barks like a dict, make it a list have to use `get` since dicts and
    # lists both have __getitem__
    if hasattr(envs, "get"):
        envs = [envs]

    for env in envs:
        if key in env:
            return env[key]

    return NO_VALUE
github zyfra / ebonite / src / ebonite / config.py View on Github external
    def __init__(self, key, namespace=None, default=NO_VALUE,
                 alternate_keys=NO_VALUE, doc='', parser: Callable = str, raise_error=True,
                 raw_value=False):
        self.key = key
        self.namespace = namespace
        self.default = default
        self.alternate_keys = alternate_keys
        self.doc = doc
        self.parser = parser
        self.raise_error = raise_error
        self.raw_value = raw_value
github willkg / everett / everett / sphinxext.py View on Github external
if more_content:
            for line, src in zip(more_content.data, more_content.items):
                self.add_line(indent + line, src[0], src[1])
            self.add_line("", "")

        if all_options:
            # Now list the options
            sourcename = "class definition"

            for option in all_options:
                self.add_line(
                    "%s:option %s %s:" % (indent, option["parser"], option["key"]),
                    sourcename,
                )
                self.add_line("%s    %s" % (indent, option["doc"]), sourcename)
                if option["default"] is not NO_VALUE:
                    self.add_line("", "")
                    self.add_line(
                        "%s    Defaults to ``%r``." % (indent, option["default"]),
                        sourcename,
                    )
                self.add_line("", "")
github willkg / everett / everett / manager.py View on Github external
def __call__(
        self,
        key,
        namespace=None,
        default=NO_VALUE,
        alternate_keys=NO_VALUE,
        doc="",
        parser=str,
        raise_error=True,
        raw_value=False,
    ):
        """Return a config value bound to a component's options.

        :arg key: the key to look up

        :arg namespace: the namespace for the key--different environments
            use this differently

        :arg default: the default value (if any); this must be a string that is
            parseable by the specified parser
github willkg / everett / everett / component.py View on Github external
def __init__(
        self,
        key,
        default=NO_VALUE,
        alternate_keys=NO_VALUE,
        doc="",
        parser=str,
        meta=None,
    ):
        self.key = key
        self.default = default
        self.alternate_keys = alternate_keys
        self.doc = doc
        self.parser = parser
        self.meta = meta or {}
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)