Writes an example config file using the config values declared so far

    :param example_file_path: path to write to
186394
def write_example_config(example_file_path: str):
    
    document = tomlkit.document()
    for header_line in _get_header():
        document.add(tomlkit.comment(header_line))
    config_keys = _aggregate_config_values(ConfigValue.config_values)
    _add_config_values_to_toml_object(document, config_keys)
    _doc_as_str = document.as_string().replace(f'"{_NOT_SET}"', '')
    with open(example_file_path, 'w') as stream:
        stream.write(_doc_as_str)
1224652
def write(settings_path, settings_data, merge=True):
    
    settings_path = Path(settings_path)
    if settings_path.exists() and merge:  # pragma: no cover
        existing = DynaconfDict()
        load(existing, str(settings_path))
        object_merge(existing, settings_data)
    with io.open(
        str(settings_path),
        "w",
        encoding=default_settings.ENCODING_FOR_DYNACONF,
    ) as f:
        f.writelines(
            [
                "{} = {}\n".format(k.upper(), repr(v))
                for k, v in settings_data.items()
            ]
        )
188258
def make_config_file(guided=False):
    
    config_path = _make_config_location(guided=guided)

    config_data = make_config_data(guided=guided)

    write_config_file(config_path, config_data)
1067216
def write_to_file(file_path, data, mkdir=False):
    
    folder, fname = os.path.split(file_path)
    return write_to_file_by_name(folder, fname, data, mkdir)
880177
def generate_example():
    
    cmd_args = sys.argv[1:]
    parser = argparse.ArgumentParser(description='Confpy example generator.')
    parser.add_argument(
        '--module',
        action='append',
        help='A python module which should be imported.',
    )
    parser.add_argument(
        '--file',
        action='append',
        help='A python file which should be evaled.',
    )
    parser.add_argument(
        '--format',
        default='JSON',
        choices=('JSON', 'INI'),
        help='The output format of the configuration file.',
    )

    args = parser.parse_args(cmd_args)

    for module in args.module or ():

        __import__(module)

    for source_file in args.file or ():

        cfg = pyfile.PythonFile(path=source_file).config

    cfg = config.Configuration()

    print(example.generate_example(cfg, ext=args.format))
741187
def _generate_examples(self, file_path):
    

    fieldnames = [
        'class_label', 'lepton_pT', 'lepton_eta', 'lepton_phi',
        'missing_energy_magnitude', 'missing_energy_phi', 'jet_1_pt',
        'jet_1_eta', 'jet_1_phi', 'jet_1_b-tag', 'jet_2_pt', 'jet_2_eta',
        'jet_2_phi', 'jet_2_b-tag', 'jet_3_pt', 'jet_3_eta', 'jet_3_phi',
        'jet_3_b-tag', 'jet_4_pt', 'jet_4_eta', 'jet_4_phi', 'jet_4_b-tag',
        'm_jj', 'm_jjj', 'm_lv', 'm_jlv', 'm_bb', 'm_wbb', 'm_wwbb'
    ]

    with tf.io.gfile.GFile(file_path) as csvfile:
      reader = csv.DictReader(csvfile, fieldnames=fieldnames)
      for row in reader:
        yield row
1099866
def create(file_path):
    """"""
    if os.path.exists(file_path):
        raise IOError("There is already a configuration file at %s" %
                      file_path)
    with open(file_path, 'w') as f:
        config = configparser.ConfigParser()
        config.add_section('misc')
        config.set('misc', 'config-version', '1.0')
        default_nb_name = os.path.split(os.path.dirname(file_path))[1]
        config.set('misc', 'nb-name', default_nb_name)
        config.add_section('root')
        config.set('root', 'path', '.')
        config.add_section('models')
        config.set('models', 'module', 'models')
        config.add_section('tests')
        config.set('tests', 'module', 'tests')
        config.add_section('suites')
        config.set('suites', 'module', 'suites')
        config.write(f)
1043386
def config_examples(dest, user_dir):
    
    examples_path = Path(lightflow.__file__).parents[1] / 'examples'
    if examples_path.exists():
        dest_path = Path(dest).resolve()
        if not user_dir:
            dest_path = dest_path / 'examples'

        if dest_path.exists():
            if not click.confirm('Directory already exists. Overwrite existing files?',
                                 default=True, abort=True):
                return
        else:
            dest_path.mkdir()

        for example_file in examples_path.glob('*.py'):
            shutil.copy(str(example_file), str(dest_path / example_file.name))
        click.echo('Copied examples to {}'.format(str(dest_path)))
    else:
        click.echo('The examples source path does not exist')
979187
public static void writeInput(Configuration conf, Path inputDir) throws IOException {
        FileSystem fs = FileSystem.get(conf);

        if (fs.exists(inputDir)) {
            throw new IOException(String.format("Input directory '%s' exists - please remove and rerun this example", inputDir));
        }

        OutputStreamWriter writer = new OutputStreamWriter(fs.create(new Path(inputDir, "input.txt")));
        for (String name : EXAMPLE_NAMES) {
            writer.write(name);
        }
        IOUtils.closeStream(writer);
    }
1031494
def build_sample_paths(sample):
    
    for path_name, path in sample.paths.items():
        print("{}: '{}'".format(path_name, path))
        base, ext = os.path.splitext(path)
        if ext:
            print("Skipping file-like: '[}'".format(path))
        elif not os.path.isdir(base):
            os.makedirs(base)
794898
def write_config(path, shape=None, dtype=None, name="conf.json", overwrite=True, credentials=None):
    
    import json
    from thunder.writers import get_file_writer

    writer = get_file_writer(path)
    conf = {'shape': shape, 'dtype': str(dtype)}

    confwriter = writer(path, name, overwrite=overwrite, credentials=credentials)
    confwriter.write(json.dumps(conf, indent=2))

    successwriter = writer(path, "SUCCESS", overwrite=overwrite, credentials=credentials)
    successwriter.write('')
583854
def write_to_file(self, file_path: str) -> None:
        
        data = self.encode()
        with open(file_path, "w") as f:
            json.dump(data, f, indent=1)
603697
def write(self):
        """"""
        with open(self.path, 'w') as f:
            self.config.write(f)
98752
def example_write_file_to_disk_if_changed():
    
    my_file = FileAsObj('/tmp/example_file.txt')
    my_file.rm(my_file.egrep('^#'))
    if my_file.changed:
        my_file.save()
331350
def writeConfig(self):
        
        with self.writeSharedFileStream('config.pickle', isProtected=False) as fileHandle:
            pickle.dump(self.__config, fileHandle, pickle.HIGHEST_PROTOCOL)
737802
def _write_file_iface(iface, data, folder, pattern):
    '''
    
    '''
    filename = os.path.join(folder, pattern.format(iface))
    if not os.path.exists(folder):
        msg = '{0} cannot be written. {1} does not exist'
        msg = msg.format(filename, folder)
        log.error(msg)
        raise AttributeError(msg)
    with salt.utils.files.fopen(filename, 'w') as fp_:
        fp_.write(salt.utils.stringutils.to_str(data))
985296
def write_tf_examples(filename, tf_examples, serialize=True):
    
    with tf.python_io.TFRecordWriter(
            filename, options=TF_RECORD_CONFIG) as writer:
        for ex in tf_examples:
            if serialize:
                writer.write(ex.SerializeToString())
            else:
                writer.write(ex)