Write a raw env value.

    A ``None`` value clears the environment variable.

    Args:
        name: The environment variable name
        value: The value to write
513060
def write(name, value):
    
    if value is not None:
        environ[name] = builtins.str(value)
    elif environ.get(name):
        del environ[name]
755285
protected function writeEnv($key, $value)
    {
        $dir = app()->environmentPath();
        $file = app()->environmentFile();
        $path = "{$dir}/{$file}";

        try {
            (new Dotenv($dir, $file))->load();

            $envKey = strtoupper($key);
            $envValue = env($envKey) ?: 'null';

            file_put_contents($path, str_replace(
                "{$envKey}={$envValue}",
                "{$envKey}={$value}",
                file_get_contents($path)
            ));
        } catch (InvalidPathException $e) {
            throw $e;
        }
    }
981977
def set_global(self, name, value):
        
        if value is None:
            # Unset the variable.
            if name in self._global:
                del self._global[name]
        self._global[name] = value
865256
def format_cli(self, value):
        
        if value is None or (self.type == 'flag' and not value):
            return None
        pass_as_bits = text_type(self.pass_as or self.default_pass_as).split()
        env = dict(name=self.name, value=value, v=value)
        return [bit.format(**env) for bit in pass_as_bits]
783377
def add_env_var(self, key, value):
        
        self.manifest['env'][key] = value
        os.environ[key] = str(value)
189566
def without_env(self, environment_variable):
        
        new_command = copy.deepcopy(self)
        new_command._env_drop.append(str(environment_variable))
        return new_command
373119
def putenv(key, value):
    

    key = path2fsn(key)
    value = path2fsn(value)

    if is_win and PY2:
        try:
            set_windows_env_var(key, value)
        except WindowsError:
            # py3 + win fails here
            raise ValueError
    else:
        try:
            os.putenv(key, value)
        except OSError:
            # win + py3 raise here for invalid keys which is probably a bug.
            # ValueError seems better
            raise ValueError
620696
def set_setting(key, val, env=None):
    
    return settings.set(key, val, env=env)
528177
def clear_environment(mode = default_env)
    case mode
      when :posix
        ENV.clear
      when :windows
        Puppet::Util::Windows::Process.get_environment_strings.each do |key, _|
          Puppet::Util::Windows::Process.set_environment_variable(key, nil)
        end
      else
        raise _("Unable to clear the environment for mode %{mode}") % { mode: mode }
    end
  end
18341
public void writeProperty(String name, String value) {
        writeElement(name, OPENING);
        _buffer.append(value);
        writeElement(name, CLOSING);
    }
860876
def clear_env_vars(names, &block)
      save_vars = {}
      names.each do |k|
        k = k.to_s
        save_vars[k] = ENV[k]
        ENV[k] = nil
      end
      begin
        yield
      ensure
        names.each do |k|
          k = k.to_s
          ENV[k] = save_vars[k]
        end
      end
      true
    end
1355278
def with_env(self, **environment_variables):
        
        new_env_vars = {
            str(var): str(val) for var, val in environment_variables.items()
        }
        new_command = copy.deepcopy(self)
        new_command._env.update(new_env_vars)
        return new_command
617728
def write(data, path, saltenv='base', index=0):
    '''
    
    '''
    if saltenv not in __opts__['pillar_roots']:
        return 'Named environment {0} is not present'.format(saltenv)
    if len(__opts__['pillar_roots'][saltenv]) <= index:
        return 'Specified index {0} in environment {1} is not present'.format(
                index, saltenv)
    if os.path.isabs(path):
        return ('The path passed in {0} is not relative to the environment '
                '{1}').format(path, saltenv)
    dest = os.path.join(__opts__['pillar_roots'][saltenv][index], path)
    dest_dir = os.path.dirname(dest)
    if not os.path.isdir(dest_dir):
        os.makedirs(dest_dir)
    with salt.utils.files.fopen(dest, 'w+') as fp_:
        fp_.write(salt.utils.stringutils.to_str(data))
    return 'Wrote data to file {0}'.format(dest)
199438
def set_env_var(key: str, value: str):
        
        elib_run.run(f'appveyor SetVariable -Name {key} -Value {value}')
        AV.info('Env', f'set "{key}" -> "{value}"')
308869
def write_properties_from_env(cls, path):
        '''
        
        '''
        with open(path, 'w') as f:
            f.write("# Autogenerated by kclboot v%s on %s\n\n" % (PACKAGE_VERSION, datetime.now()))
            for env_var, prop_var in ENV_TO_PROPERTY.items():
                env_value = os.environ.get(env_var)
                if env_value:
                    f.write("%s=%s\n" % (prop_var, env_value))
151963
def setnx(self, name, value):
        
        with self.pipe as pipe:
            return pipe.setnx(self.redis_key(name),
                              self.valueparse.encode(value))
406124
def environment_as(**kwargs):
  
  new_environment = kwargs
  old_environment = {}

  def setenv(key, val):
    if val is not None:
      os.environ[key] = val if PY3 else _os_encode(val)
    else:
      if key in os.environ:
        del os.environ[key]

  for key, val in new_environment.items():
    old_environment[key] = os.environ.get(key)
    setenv(key, val)
  try:
    yield
  finally:
    for key, val in old_environment.items():
      setenv(key, val)