Adds an environment variable.

    Args:
      environment_variable (EnvironmentVariableArtifact): environment variable
          artifact.

    Raises:
      KeyError: if the environment variable already exists.
765936
def AddEnvironmentVariable(self, environment_variable):
    
    name = environment_variable.name.upper()
    if name in self._environment_variables:
      raise KeyError('Environment variable: {0:s} already exists.'.format(
          environment_variable.name))

    self._environment_variables[name] = environment_variable
591029
def add_to_environment(self, environment):
        """"""
        self._env = environment._env
        self._userdata = ffi.new_handle(self)

        ENVIRONMENT_DATA[self._env].routers[self.name] = self

        lib.EnvAddRouterWithContext(
            self._env, self._name.encode(), self._priority,
            lib.query_function,
            lib.print_function,
            lib.getc_function,
            lib.ungetc_function,
            lib.exit_function,
            self._userdata)
597737
def add(self, key, value):
        
        if isinstance(value, list):
            # TODO: support env vars in list w/masked values
            for val in value:
                self._add_arg_python(key, val)
        elif isinstance(value, dict):
            err = 'Dictionary types are not currently supported for field.'
            print('{}{}{}'.format(c.Style.BRIGHT, c.Fore.RED, err))
        else:
            mask = False
            env_var = re.compile(r'^\$env\.(.*)$')
            envs_var = re.compile(r'^\$envs\.(.*)$')

            if env_var.match(str(value)):
                # read value from environment variable
                env_key = env_var.match(str(value)).groups()[0]
                value = os.environ.get(env_key, value)
            elif envs_var.match(str(value)):
                # read secure value from environment variable
                env_key = envs_var.match(str(value)).groups()[0]
                value = os.environ.get(env_key, value)
                mask = True
            self._add_arg(key, value, mask)
1196321
def set_env_value(obj, attribute, value):
    
    varname = get_env_key(obj, attribute)
    os.environ[varname] = value
    return varname
1348807
def get_env_variable(var_name, default=None):
    """"""
    try:
        return os.environ[var_name]
    except KeyError:
        if default is None:
            error_msg = "Set the %s environment variable" % var_name
            raise ImproperlyConfigured(error_msg)
        else:
            return default
123087
public UpdateAppRequest withEnvironmentVariables(java.util.Map<String, String> environmentVariables) {
        setEnvironmentVariables(environmentVariables);
        return this;
    }
1228008
public void addEnv(final Environment.Variable var) {
    this.compilerDef.addEnv(var);
    for (int i = 0; i < this._compilers.size(); i++) {
      final CompilerDef currentCompilerDef = this._compilers.elementAt(i);
      currentCompilerDef.addEnv(var);
    }
    this.linkerDef.addEnv(var);
  }
423771
def set_env_variables(stack, grid, platform = grid)
      ENV['STACK'] = stack
      ENV['GRID'] = grid
      ENV['PLATFORM'] = platform
    end
750667
def add(self, **kwargs):
        
        for name, var in kwargs.items():
            if iskeyword(name):
                var['name'] = name
                name = '_' + name
            if name in self:
                self[name] = merge(self[name], Variable(self.default_type, **var))
            else:
                self[name] = Variable(self.default_type, **var)
        return self
31579
def add_env(self, name, val):
        '''
        '''
        if name in self.env_vars:
            raise KeyError(name)
        self.env_vars[name] = val
1268881
def add_var_arg(self, arg):
    
    self.__args.append(arg)
    self.__job.add_var_arg(self.__arg_index)
    self.__arg_index += 1
545857
def env_or_default(var, default=None):
    
    if var in os.environ:
        return os.environ[var]
    return default
1008528
def getenvar(self, envar):
        from os import getenv
        """"""
        if getenv(envar) is not None:
            self._vardict[envar] = getenv(envar)
664330
def create_environment(preamble):
    
    environment = copy.deepcopy(os.environ)
    for line in preamble:
        logging.debug(line)
        if "=" in line and not line.startswith("#"):
            tmp = line.split("=")
            key = tmp[0].strip()
            value = tmp[1].strip()
            logging.debug(
                "Found variable {} with value {}".format(key, value))
            environment.update({key: value})
    logging.debug("Env {}".format(environment))
    return environment
878108
def environment_variable(key, value):
    

    if key not in os.environ:
        previous = None
    else:
        previous = os.environ[key]

    os.environ[key] = value

    yield

    if previous is None:
        del os.environ[key]
    else:
        os.environ[key] = previous
1188979
def from_envvar(self, variable_name):
        
        config_file = os.environ.get(variable_name)
        if not config_file:
            raise RuntimeError(
                "The environment variable %r is not set and "
                "thus configuration could not be loaded." % variable_name
            )
        return self.from_pyfile(config_file)
1058819
def substitute_environ(self):
        
        for attr_name in dir(self):
            if attr_name.startswith('_') or attr_name.upper() != attr_name:
                continue

            orig_value = getattr(self, attr_name)
            is_required = isinstance(orig_value, Required)
            orig_type = orig_value.v_type if is_required else type(orig_value)
            env_var_name = self._ENV_PREFIX + attr_name
            env_var = os.getenv(env_var_name, None)
            if env_var is not None:
                if issubclass(orig_type, bool):
                    env_var = env_var.upper() in ('1', 'TRUE')
                elif issubclass(orig_type, int):
                    env_var = int(env_var)
                elif issubclass(orig_type, Path):
                    env_var = Path(env_var)
                elif issubclass(orig_type, bytes):
                    env_var = env_var.encode()
                # could do floats here and lists etc via json
                setattr(self, attr_name, env_var)
            elif is_required and attr_name not in self._custom_settings:
                raise RuntimeError('The required environment variable "{0}" is currently not set, '
                                   'you\'ll need to run `source activate.settings.sh` '
                                   'or you can set that single environment variable with '
                                   '`export {0}="<value>"`'.format(env_var_name))