Parse the environment value for a given key against the schema.

        Args:
            key: The name of the environment variable.
            value: The value to be parsed.
334149
def parse(self, key, value):
        
        if value is not None:
            try:
                return self._parser(value)
            except Exception:
                raise ParsingError("Error parsing {}".format(key))
        elif self._default is not SENTINAL:
            return self._default
        else:
            raise KeyError(key)
803659
def get_env_value(obj, attribute):
    
    varname = get_env_key(obj, attribute)
    var = os.environ.get(varname)
    if not var:
        raise ValueError("%s must be set in your environment." % varname)

    return var
1221494
def html_for_env_var(key):
    
    value = os.getenv(key)
    return KEY_VALUE_TEMPLATE.format(key, value)
1229052
def set(self, key, value):
        
        d = self.data.data
        keys = key.split('.')
        latest = keys.pop()
        for k in keys:
            d = d.setdefault(k, {})

        schema = Schema().load(self.schema_file)

        self.data.internal = schema.internal
        self.parse_value(d, '', key, value, schema.get(key))
        self.data.save(self.data_file)
911739
def fetch_value(key)
      val = fetch_nested(key)
      return val if self[:no_pruning].include?(key)
      Prunable::VALUES.include?(val) ? Prunable::Value : val
    end
603699
def get(cls, key, default=None, separator='.', global_=False):
        
        # first check environnment variables
        # if we're not in global scope
        if not global_:
            ret = os.environ.get(key.upper().replace('.', '_'))
            if ret is not None:
                return ret

        # then check in local and global configuration unless global_=True
        scopes = ['global'] if global_ else ['local', 'global']
        for scope in scopes:
            ret = cls._get(scope, key, default, separator)
            if ret is not None and ret != default:
                return ret

        if ret is None or ret == default:
            return default
1035965
def set_value(self, key, value):
        # type: (str, Any) -> None
        
        self._ensure_have_load_only()

        fname, parser = self._get_parser_to_modify()

        if parser is not None:
            section, name = _disassemble_key(key)

            # Modify the parser and the configuration
            if not parser.has_section(section):
                parser.add_section(section)
            parser.set(section, name, value)

        self._config[self.load_only][key] = value
        self._mark_as_modified(fname, parser)
614785
function get(key) {

    let val = process.env[key];

    return val in types ? types[val] : util.isNumeric(val) ? parseFloat(val) : val;

}
3351
def extract_key_value(line, environ):
    
    segments = line.split("=", 1)
    if len(segments) < 2:
        return None
    key, value = segments
    # foo passes through as-is (with spaces stripped)
    # '{foo}' passes through literally
    # "{foo}" substitutes from environ's foo
    value = value.strip()
    if value[0] == "'" and _SQUOTE_RE.match(value):
        value = value[1:-1]
    elif value[0] == '"' and _DQUOTE_RE.match(value):
        template = value[1:-1]
        value = template.format(**environ)
    key = key.strip()
    value = value.strip()
    return key, value
723131
def get_service_env_value(self, key):
        
        service_key = predix.config.get_env_key(self, key)
        value = os.environ[service_key]
        if not value:
            raise ValueError("%s env unset" % key)
        return value
968587
def _find(self, key):
        
        key = self._real_key(key)

        # OVERRIDES
        val = self._override.get(key)
        if val is not None:
            log.debug("{0} found in override: {1}".format(key, val))
            return val

        # ARGS
        val = self._args.get(key)
        if val is not None:
            log.debug("{0} found in args: {1}".format(key, val))
            return val

        # ENVIRONMENT VARIABLES
        if self._automatic_env_applied:
            # even if it hasn't been registered, if `automatic_env` is used,
            # check any `get` request
            val = self._get_env(self._merge_with_env_prefix(key))
            if val is not None:
                log.debug("{0} found in environment: {1}".format(key, val))
                return val

        env_key = self._find_insensitive(key, self._env)
        log.debug("Looking for {0} in env".format(key))
        if isinstance(env_key, list):
            parent = self._find_insensitive(key, self._config)
            found_in_env = False
            log.debug("Found env key parent {0}: {1}".format(key, parent))

            for item in env_key:
                log.debug("{0} registered as env var parent {1}:".format(
                    key, item["env_key"]))
                val = self._get_env(item["env_key"])

                if val is not None:
                    log.debug("{0} found in environment: {1}".format(
                        item["env_key"], val))
                    temp = parent
                    for path in item["path"]:
                        real_key = self._find_real_key(path, temp)
                        temp = temp[real_key]

                    self._set_insensitive(item["final_key"], val, temp)
                    found_in_env = True
                else:
                    log.debug("{0} env value unset".format(item["env_key"]))

            if found_in_env:
                return parent

        elif env_key is not None:
            log.debug("{0} registered as env var: {1}".format(key, env_key))
            val = self._get_env(env_key)
            if val is not None:
                log.debug("{0} found in environment: {1}".format(env_key, val))
                return val
            else:
                log.debug("{0} env value unset".format(env_key))

        # CONFIG FILE
        val = self._find_insensitive(key, self._config)
        if val is not None:
            log.debug("{0} found in config: {1}".format(key, val))
            return val

        # Test for nested config parameter
        if self._key_delimiter in key:
            path = key.split(self._key_delimiter)

            source = self._find(path[0])
            if source is not None and isinstance(source, dict):
                val = self._search_dict(source, path[1::])
                if val is not None:
                    log.debug("{0} found in nested config: {1}".format(
                        key, val))
                    return val

        # KEY/VALUE STORE
        val = self._kvstore.get(key)
        if val is not None:
            log.debug("{0} found in key/value store: {1}".format(key, val))
            return val

        # DEFAULTS
        val = self._defaults.get(key)
        if val is not None:
            log.debug("{0} found in defaults: {1}".format(key, val))
            return val

        return None
511219
def get_optional_env(key):
    
    environment_variable_value = os.environ.get(key)
    if environment_variable_value:
        return environment_variable_value
    elif key in CONSTANTS:
        return CONSTANTS[key]
    else:
        raise Exception("The variable {1} is not set".format(key))
1050368
def set_key(dotenv_path, key_to_set, value_to_set, quote_mode="always"):
    
    value_to_set = value_to_set.strip("'").strip('"')
    if not os.path.exists(dotenv_path):
        warnings.warn("can't write to %s - it doesn't exist." % dotenv_path)
        return None, key_to_set, value_to_set

    if " " in value_to_set:
        quote_mode = "always"

    line_template = '{}="{}"\n' if quote_mode == "always" else '{}={}\n'
    line_out = line_template.format(key_to_set, value_to_set)

    with rewrite(dotenv_path) as (source, dest):
        replaced = False
        for mapping in parse_stream(source):
            if mapping.key == key_to_set:
                dest.write(line_out)
                replaced = True
            else:
                dest.write(mapping.original)
        if not replaced:
            dest.write(line_out)

    return True, key_to_set, value_to_set
497035
def get_config_value_from_file(key, config_path=None, default=None):
    
    config = _get_config_dict_from_file(config_path)
    if key not in config:
        return default
    return config[key]
881305
def from_env(key: str, default: T = None) -> Union[str, Optional[T]]:
    
    return os.getenv(key, default)
338565
def _parse_env_var_file(data):
    

    output = {}
    for line in data.splitlines():
        line = line.strip()
        if not line or '=' not in line:
            continue
        parts = line.split('=')
        if len(parts) != 2:
            continue
        name = parts[0]
        value = parts[1]
        if len(value) > 1:
            if value[0] == '"' and value[-1] == '"':
                value = value[1:-1]
        output[name] = value
    return output
459674
def set(self, key, value):
        ''''''
        if hasattr(value, 'labels'):
            if 'VARIABLE' in env.config['SOS_DEBUG'] or 'ALL' in env.config[
                    'SOS_DEBUG']:
                env.log_to_file(
                    'VARIABLE',
                    f"Set {key} to {short_repr(value)} with labels {short_repr(value.labels)}"
                )
        else:
            if 'VARIABLE' in env.config['SOS_DEBUG'] or 'ALL' in env.config[
                    'SOS_DEBUG']:
                env.log_to_file(
                    'VARIABLE',
                    f"Set {key} to {short_repr(value)} of type {value.__class__.__name__}"
                )
        self._dict[key] = value