See ConfigParser.write().  Also writes secure items to keystore.
179604
def write(self, *args):
        """"""
        ConfigParser.write(self, *args)
        if self.keyring_available:
            for key, thing in self._unsaved.items():
                action = thing[0]
                value = thing[1]
                if action == 'set':
                    keyring.set_password(self.keyring_name, key, value)
                elif action == 'delete':
                    try:
                        keyring.delete_password(self.keyring_name, key)
                    except:
                        pass
        self._unsaved = {}
671959
protected void storeSecurity(DsSecurity s, XMLStreamWriter writer) throws Exception
   {
      writer.writeStartElement(XML.ELEMENT_SECURITY);

      if (s.getUserName() != null)
      {
         writer.writeStartElement(XML.ELEMENT_USER_NAME);
         writer.writeCharacters(s.getValue(XML.ELEMENT_USER_NAME, s.getUserName()));
         writer.writeEndElement();

         writer.writeStartElement(XML.ELEMENT_PASSWORD);
         writer.writeCharacters(s.getValue(XML.ELEMENT_PASSWORD, s.getPassword()));
         writer.writeEndElement();
      }
      else if (s.getSecurityDomain() != null)
      {
         writer.writeStartElement(XML.ELEMENT_SECURITY_DOMAIN);
         writer.writeCharacters(s.getValue(XML.ELEMENT_SECURITY_DOMAIN, s.getSecurityDomain()));
         writer.writeEndElement();
      }

      if (s.getReauthPlugin() != null)
      {
         storeExtension(s.getReauthPlugin(), writer, XML.ELEMENT_REAUTH_PLUGIN);
      }

      writer.writeEndElement();
   }
466260
def write(self, filename):
        
        ext = os.path.splitext(filename)[1]
        writer = open(filename, 'w')
        if ext == '.py':
            writer.write(pprint.pformat(self))
        elif ext == '.yaml':
            writer.write(yaml.dump(self))
        else:
            writer.close()
            raise Exception('Unrecognized config format: %s'%ext)
        writer.close()
448029
def write_config(ip, mac, single, double, long, touch):
    """"""
    click.echo("Write configuration to device %s" % ip)
    data = {
        'single': single,
        'double': double,
        'long': long,
        'touch': touch,
    }
    request = requests.post(
        'http://{}/{}/{}/'.format(ip, URI, mac), data=data, timeout=TIMEOUT)

    if request.status_code == 200:
        click.echo("Configuration of %s set" % mac)
218567
def Persist(self, config_option):
    """"""
    if not self.writeback:
      raise RuntimeError("Attempting to write a configuration without a "
                         "writeback location.")

    writeback_raw_value = dict(self.writeback.RawData()).get(config_option)
    raw_value = None

    for parser in [self.parser] + self.secondary_config_parsers:
      if parser == self.writeback:
        continue

      config_raw_data = dict(parser.RawData())
      raw_value = config_raw_data.get(config_option)
      if raw_value is None:
        continue
      break

    if writeback_raw_value == raw_value:
      return

    if raw_value is None:
      return

    self.SetRaw(config_option, raw_value)
    self.Write()
536501
@Override
    public void write(final Writer writer) throws ConfigurationException, IOException {
        Preconditions.checkNotNull(writer);

        @SuppressWarnings("unchecked") final
        HashMap<String, Object> settings = (HashMap<String, Object>) fromNode(this.getModel().getInMemoryRepresentation());
        this.mapper.writerWithDefaultPrettyPrinter().writeValue(writer, settings);
    }
851315
def write(obj, data=None, **kwargs):
    
    if obj.VAULT_ENABLED_FOR_DYNACONF is False:
        raise RuntimeError(
            "Vault is not configured \n"
            "export VAULT_ENABLED_FOR_DYNACONF=true\n"
            "and configure the VAULT_FOR_DYNACONF_* variables"
        )
    data = data or {}
    data.update(kwargs)
    if not data:
        raise AttributeError("Data must be provided")
    client = get_client(obj)
    path = "/".join(
        [obj.VAULT_PATH_FOR_DYNACONF, obj.current_env.lower()]
    ).replace("//", "/")
    client.write(path, data=data)
    load(obj)
1242935
def set_config(self, key, value):
        ''''''
        self.config = self.read_file()
        self.config[key] = value
        self.write_file()
727222
def write(self, section, option, value):
        
        self.config.read(self.filepath)
        string = tidy_headers._parse_item.item2string(value, sep=", ")
        self.config.set(section, option, string)
        with open(self.filepath, "w") as f:
            self.config.write(f)
1335334
def write(self, items):
        

        if self._read_only:
            raise IOError("Cannot write, Connector created as Read Only")

        # Uploading info to the new ES
        rows = items.to_dict("index")
        docs = []
        for row_index in rows.keys():
            row = rows[row_index]
            item_id = self.make_hashcode(row[Events.PERCEVAL_UUID], row[Git.FILE_PATH], row[Git.FILE_EVENT])
            row['uuid'] = item_id
            doc = {
                "_index": self._es_index,
                "_type": "items",
                "_id": item_id,
                "_source": row
            }
            docs.append(doc)
        # TODO exception and error handling
        chunk_size = 2000
        chunks = [docs[i:i + chunk_size] for i in range(0, len(docs), chunk_size)]
        for chunk in chunks:
            helpers.bulk(self._es_conn, chunk)
        logger.info(self.__log_prefix + "Written: " + str(len(docs)))
650423
function writeClientConfig(client, clientId, configs, callback) {
  debug('writeClientConfig: "%s", %j', clientId, configs);
  updateEntityConfig(client, getClientConfigPath(clientId), configs, callback);
}
256444
def _storeConfig(self, config, configPath):
        
        self.logger.info("Writing to " + str(configPath))
        os.makedirs(os.path.dirname(configPath), exist_ok=True)
        with (open(configPath, 'w')) as yml:
            yaml.dump(config, yml, default_flow_style=False)
1218153
def write_config_value_to_file(key, value, config_path=None):
    
    if config_path is None:
        config_path = DEFAULT_CONFIG_PATH

    # Get existing config.
    config = _get_config_dict_from_file(config_path)

    # Add/update the key/value pair.
    config[key] = value

    # Create parent directories if they are missing.
    mkdir_parents(os.path.dirname(config_path))

    # Write the content
    with open(config_path, "w") as fh:
        json.dump(config, fh, sort_keys=True, indent=2)

    # Set 600 permissions on the config file.
    os.chmod(config_path, 33216)

    return get_config_value_from_file(key, config_path)
1255211
def write_config(self, access_token):
        
        self.config.add_section('exist')

        # TODO: config is reading 'None' as string during authorization, so clearing this out
        # if no id or secret is set - need to fix this later
        if self.client_id:
            self.config.set('exist', 'client_id', self.client_id)
        else:
            self.config.set('exist', 'client_id', '')

        if self.client_secret:
            self.config.set('exist', 'client_secret', self.client_secret)
        else:
            self.config.set('exist', 'client_secret', '')

        self.config.set('exist', 'access_token', access_token)

        with open(self.config_file, 'w') as cfg:
            self.config.write(cfg)
        print('Credentials written to %s' % self.config_file)
663946
def write_config(path, config):
    
    config_as_string = to_nice_yaml(config)

    config_as_string = "---\n" + config_as_string

    string_to_file(path, config_as_string)
804606
def load(keystorerc=None, keystore=None, copyto=None, verbose=False):
  ''''''

  config = None
  if keystorerc:
    config = config_reader.read(keystorerc)
    if not config:
      print('No configuration found.', file=sys.stderr)
      sys.exit(-1)
  elif keystore:
    config = {
      'keystore': keystore,
      'files': []
    }

  if 'verbose' in config and config['verbose']:
    verbose = True

  keystore_path = None
  if 'keystore' not in config:
    print('.keystorerc needs to specify a keystore file path.', file=sys.stderr)
    sys.exit(-1)
  elif not pathlib.Path(os.path.expanduser(config['keystore'])).is_file():
    # If keystore file does not exist, nothing to load and exits
    print('keystore does not exist: {}'.format(config['keystore']), file=sys.stderr)
    sys.exit(-1)
  else:
    keystore_path = config['keystore']

  if copyto and not pathlib.Path(os.path.expanduser(copyto)).is_dir():
    print('The folder to copy to does not exist: {}'.format(copyto), file=sys.stderr)
    sys.exit(-1)

  # load and attempt to unencrypt keystore by passphrase

  encrypted_keystore = None
  try:
    with open(os.path.expanduser(keystore_path), 'rb') as keystore_file:
      encrypted_keystore = keystore_file.read()

    if verbose: print('Located encrypted keystore at {}.'.format(keystore_path))

    decrypted = False
    decrypted_keystore = None
    while not decrypted:
      try:
        passphrase = getpass.getpass('Please enter the passphrase: ')
        decrypted_keystore = simplecrypt.decrypt(passphrase, encrypted_keystore)
        decrypted = True
      except simplecrypt.DecryptionException as err:
        print('Invalid passphrase. Please try again.')
      except UnicodeDecodeError as err:
        print('Keyring cannot be decrypted.\nError: {}'.format(err), file=sys.stderr)
        sys.exit(-1)

  except OSError as err:
    print('keystore cannot be opened: {}'.format(err), file=sys.stderr)
    sys.exit(-1)

  # attempt to uncompress the keystore

  decompressed_keystore = gzip.decompress(decrypted_keystore)

  # attempt to unserialise the keystore

  try:
    keystore = json.loads(decompressed_keystore)
  except json.decoder.JSONDecodeError as err:
    print('Please contact the author about this as this is a serious problem. {}'.format(err), file=sys.stderr)
    sys.exit(-1)

  if verbose: print('Keystore decrypted successfully.')

  count = 0
  for filepath, key in keystore.items():
    expanded_filepath = os.path.expanduser(filepath)
    if copyto:
      expanded_filepath = os.path.join(copyto, os.path.basename(filepath))

    confirmed = False
    overwrite = False
    if not pathlib.Path(expanded_filepath).exists():
      confirmed = True
      overwrite = True

    while not confirmed:
      overwrite = input('File {} exists. Are you sure you want to overwrite? (y)/n: '.format(expanded_filepath))
      if overwrite == '' or overwrite == 'y' or overwrite == 'Y':
        overwrite = True
        confirmed = True
      elif overwrite == 'n' or overwrite == 'N':
        overwrite = False
        confirmed = True
      else:
        print('Please enter y or n.')
    if not overwrite:
      continue

    # key ready to be created
    if verbose: print('Writing key to {} ...'.format(expanded_filepath))
    try:
      with open(expanded_filepath, 'wb') as keyfile:
        b64_decoded = base64.decodebytes(key.encode('utf-8'))
        keyfile.write(b64_decoded)
      count += 1
    except OSError as err:
      print('File system threw an error: {}'.format(err), file=sys.stderr)
      print('Skipping {}'.format(expanded_filepath))

  if verbose: print('Keystore restored {} keys.'.format(count))
860057
function _gpfStreamSecureWrite(write) {
        return function (buffer) {
            var me = this;
            //eslint-disable-line no-invalid-this
            _gpfStreamProgressStartWrite(me);
            return _gpfStreamSecureEnd(write.call(me, buffer), me, _gpfStreamProgressEndWrite);
        };
    }