Writes a configuration file using the settings array.
199764
public function Write()
    {
        file_put_contents(
            $this->file,
            \Peg\Lib\Utilities\Json::Encode($this->preferences)
        );
    }
851367
public static void writeConfigFile(File configFile, Class<?>[] classes, boolean sortClasses)
			throws SQLException, IOException {
		System.out.println("Writing configurations to " + configFile.getAbsolutePath());
		writeConfigFile(new FileOutputStream(configFile), classes, sortClasses);
	}
386889
def write_config(data, conf_dir=DEFAULT_CONFIG_DIR, codec="yaml",
                 backup_existing=False):
    
    if not codec:
        codec = 'yaml'
    codec = munge.get_codec(codec)()
    conf_dir = os.path.expanduser(conf_dir)
    if not os.path.exists(conf_dir):
        os.mkdir(conf_dir)

    # Check for existing file, back up if necessary
    outpath = os.path.join(conf_dir, 'config.' + codec.extensions[0])
    if backup_existing and os.path.exists(outpath):
        os.rename(outpath, outpath + '.bak')
    codec.dump(data, open(outpath, 'w'))
958753
def _write_conf(conf, path=MAIN_CF):
    '''
    
    '''
    with salt.utils.files.fopen(path, 'w') as fh_:
        for line in conf:
            line = salt.utils.stringutils.to_str(line)
            if isinstance(line, dict):
                fh_.write(' '.join(line))
            else:
                fh_.write(line)
            fh_.write('\n')
1157532
def write(self, config_dir=None, config_name=None, codec=None):
        
        # get name of config directory
        if not config_dir:
            config_dir = self._meta_config_dir
            if not config_dir:
                raise IOError("config_dir not set")

        # get name of config file
        if not config_name:
            config_name = self._defaults.get('config_name', None)
        if not config_name:
            raise KeyError('config_name not set')

        if codec:
            codec = munge.get_codec(codec)()
        else:
            codec = munge.get_codec(self._defaults['codec'])()

        config_dir = os.path.expanduser(config_dir)
        if not os.path.exists(config_dir):
            os.mkdir(config_dir)

        codec.dumpu(self.data, os.path.join(config_dir, 'config.' + codec.extension))
118428
function writeConfigFile(config, yoRcPath = '.yo-rc.json') {
  let newYoRc = { ...config };
  if (FileUtils.doesFileExist(yoRcPath)) {
    const yoRc = JSON.parse(fs.readFileSync(yoRcPath, { encoding: 'utf-8' }));
    newYoRc = {
      ...yoRc,
      ...config,
      [GENERATOR_NAME]: {
        ...yoRc[GENERATOR_NAME],
        ...config[GENERATOR_NAME]
      }
    };
  }
  fs.writeFileSync(yoRcPath, JSON.stringify(newYoRc, null, 2));
}
113532
def write(self):
        """"""
        self._assure_writable("write")
        if not self._dirty:
            return

        if isinstance(self._file_or_files, (list, tuple)):
            raise AssertionError("Cannot write back if there is not exactly a single file to write to, have %i files"
                                 % len(self._file_or_files))
        # end assert multiple files

        if self._has_includes():
            log.debug("Skipping write-back of configuration file as include files were merged in." +
                      "Set merge_includes=False to prevent this.")
            return
        # end

        fp = self._file_or_files

        # we have a physical file on disk, so get a lock
        is_file_lock = isinstance(fp, string_types + (FileType, ))
        if is_file_lock:
            self._lock._obtain_lock()
        if not hasattr(fp, "seek"):
            with open(self._file_or_files, "wb") as fp:
                self._write(fp)
        else:
            fp.seek(0)
            # make sure we do not overwrite into an existing file
            if hasattr(fp, 'truncate'):
                fp.truncate()
            self._write(fp)
429871
def write(self, fn=None, sorted=False, wait=0):
        
        config = ConfigParser(interpolation=None)
        if sorted==True: keys.sort()
        for key in self.__dict__.get('ordered_keys') or self.keys():
            config[key] = {}
            ks = self[key].keys()
            if sorted==True: ks.sort()
            for k in ks:
                if type(self[key][k])==list and self.__join_list__ is not None:
                    config[key][k] = self.__join_list__.join([v for v in self[key][k] if v!=''])
                else:
                    config[key][k] = str(self[key][k])
        fn = fn or self.__dict__.get('__filename__')
        # use advisory locking on this file
        i = 0
        while os.path.exists(fn+'.LOCK') and i < wait:
            i += 1
            time.sleep(1)
        if os.path.exists(fn+'.LOCK'):
            raise FileExistsError(fn + ' is locked for writing')
        else:
            with open(fn+'.LOCK', 'w') as lf:
                lf.write(time.strftime("%Y-%m-%d %H:%M:%S %Z"))
            with open(fn, 'w') as f:
                config.write(f)
            os.remove(fn+'.LOCK')
1247715
public function writeConfiguration()
    {
        $configFile= APP_PATH.'config/database.php';
        $config    = $this->getPostConfiguration();

        $configStr = <<<CONFIG
<?php

\$config['database'] = array(
    'default'       => '{$config['driver']}',

    'connections'   => array(
        '{$config['driver']}'     => array(
            'driver'    => '{$config['driver']}',
            'host'      => isset(\$_SERVER['DB1_HOST']) ? \$_SERVER['DB1_HOST'] : '{$config['host']}',
            'database'  => isset(\$_SERVER['DB1_NAME']) ? \$_SERVER['DB1_NAME'] : '{$config['database']}',
            'username'  => isset(\$_SERVER['DB1_USER']) ? \$_SERVER['DB1_USER'] : '{$config['username']}',
            'password'  => isset(\$_SERVER['DB1_PASS']) ? \$_SERVER['DB1_PASS'] : '{$config['password']}',
            'charset'   => '{$config['charset']}',
            'collation' => '{$config['collation']}',
            'prefix'    => '{$config['prefix']}'
        )
    )
);
CONFIG;

        file_put_contents($configFile, $configStr);

        $this->makeConnection($config);
        $this->migrate();
        $this->seed();

        Response::redirect($this->data['baseUrl'].'install.php/finish');
    }
998453
private static <T> void writeConfig(BufferedWriter writer, DatabaseTableConfig<T> config) throws IOException,
			SQLException {
		writer.append(CONFIG_FILE_START_MARKER);
		writer.newLine();
		if (config.getDataClass() != null) {
			writer.append(FIELD_NAME_DATA_CLASS).append('=').append(config.getDataClass().getName());
			writer.newLine();
		}
		if (config.getTableName() != null) {
			writer.append(FIELD_NAME_TABLE_NAME).append('=').append(config.getTableName());
			writer.newLine();
		}
		writer.append(CONFIG_FILE_FIELDS_START);
		writer.newLine();
		if (config.getFieldConfigs() != null) {
			for (DatabaseFieldConfig field : config.getFieldConfigs()) {
				DatabaseFieldConfigLoader.write(writer, field, config.getTableName());
			}
		}
		writer.append(CONFIG_FILE_FIELDS_END);
		writer.newLine();
		writer.append(CONFIG_FILE_END_MARKER);
		writer.newLine();
	}
185406
def save(self, filename=None, debug=False):
        """"""
        if not filename: filename = self.name
        with open(filename, "w") as f: # save config data file
            f.write(self.toJson(self.attrs))
        if self.debug or debug:
            print("saved configuration %s"%(self.name))
            for k,v in sorted(iteritems(self.attrs)):
                print("%15s : %s"%(k,v))
176423
public static void writeConfigFile(OutputStream outputStream, File searchDir) throws SQLException, IOException {
		writeConfigFile(outputStream, searchDir, false);
	}
685371
def _write_config_file(items, global_vars, template, project_name, out_dir,
                       remotes):
    
    config_dir = utils.safe_makedir(os.path.join(out_dir, "config"))
    out_config_file = os.path.join(config_dir, "%s.yaml" % project_name)
    out = {"fc_name": project_name,
           "upload": {"dir": "../final"},
           "details": items}
    if remotes.get("base"):
        r_base = objectstore.parse_remote(remotes.get("base"))
        out["upload"]["method"] = r_base.store
        out["upload"]["bucket"] = r_base.bucket
        out["upload"]["folder"] = os.path.join(r_base.key, "final") if r_base.key else "final"
        if r_base.region:
            out["upload"]["region"] = r_base.region
    if global_vars:
        out["globals"] = global_vars
    for k, v in template.items():
        if k not in ["details"]:
            out[k] = v
    if os.path.exists(out_config_file):
        shutil.move(out_config_file,
                    out_config_file + ".bak%s" % datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S"))
    with open(out_config_file, "w") as out_handle:
        yaml.safe_dump(out, out_handle, default_flow_style=False, allow_unicode=False)
    return out_config_file
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)
106720
def __write_p4settings(self, config):
        
        self.logger.info("Writing p4settings...")
        root_dir = os.path.expanduser(config.get('root_path'))
        p4settings_path = os.path.join(root_dir, ".p4settings")
        if os.path.exists(p4settings_path):
            if self.target.get('overwrite_p4settings', False):
                self.logger.info("Overwriting existing p4settings...")
                os.remove(p4settings_path)
            else:
                return
        with open(p4settings_path, "w+") as p4settings_file:
            p4settings_file.write(p4settings_template % config.to_dict())
            if config.get('write_password_p4settings', 'no'):
                p4settings_file.write("\nP4PASSWD=%s" % config['password'])
292518
def write(settings_path, settings_data, merge=True):
    
    settings_path = Path(settings_path)
    if settings_path.exists() and merge:  # pragma: no cover
        with io.open(
            str(settings_path), encoding=default_settings.ENCODING_FOR_DYNACONF
        ) as open_file:
            object_merge(ConfigObj(open_file).dict(), settings_data)
    new = ConfigObj()
    new.update(settings_data)
    new.write(open(str(settings_path), "bw"))
495555
public static void writeConfigFile(File configFile, boolean sortClasses) throws SQLException, IOException {
		writeConfigFile(configFile, new File("."), sortClasses);
	}