Writing multiple files to given dir.
169756
def write_analyzed(dir)
      FileUtils.mkdir_p(dir)

      attributes.each do |a, v|
        path = File.join(dir, a.to_s)
        s = "Count|Value\n" + v.map { |e| "#{e[:count]}|#{e[:value]}" }.join("\n")
        File.open("#{path}.csv", 'w') { |f| f.write(s) }
      end
    end
70896
def copy_files_to_folder(files, target_folder, overwrite=True):
    
    if not files:
        return []

    for f in files:
        target = os.path.join(target_folder, os.path.split(f)[-1])

        if target == f:
            # both file path are the same!
            return target

        if os.path.exists(target):
            if overwrite:
                # remove the file before copying
                try:
                    os.remove(target)
                except Exception:
                    raise IOError("Failed to remove %s" % f)
                else:
                    shutil.copy(f, target)
            else:
                continue
        else:
            print('Copying %s to %s' % (os.path.split(f)[-1],
                                        os.path.normpath(target_folder)))
            shutil.copy(f, target)

    return [os.path.join(target_folder, os.path.split(f)[-1]) for f in files]
389433
function createFiles (num, dir) {
  for (var i = 0; i <= num; i++) {
    fs.writeFileSync(path.join(dir, 'test-' + i + '.txt'), String(i));
  }
}
343345
def prepare_writeable_dir(tree):
    '''  '''

    if tree != '/':
        tree = os.path.realpath(os.path.expanduser(tree))
    if not os.path.exists(tree):
        try:
            os.makedirs(tree)
        except (IOError, OSError), e:
            exit("Could not make dir %s: %s" % (tree, e))
    if not os.access(tree, os.W_OK):
        exit("Cannot write to path %s" % tree)
794215
private static void getFilesAndDirs(File dir, List<File> list) {
        File[] files = dir.listFiles();
        for (File element : files) {
            list.add(element);
            if (element.isDirectory()) {
                getFilesAndDirs(element, list);
            }
        }
    }
382463
def dir_files(dir)
      Find.find(dir).to_a.reject!{|f| File.directory?(f) }
    end
866167
def write(self, arg, **kwargs):
        """"""
        if hasattr(arg, 'seek'):
            self._tofile(arg, **kwargs)
        else:
            with open(arg, 'wb') as fid:
                self._tofile(fid, **kwargs)
563759
def _write_to_filepath(content, output):
    
    outdir = os.path.dirname(output)
    if outdir and not os.path.exists(outdir):
        os.makedirs(outdir)

    with anytemplate.compat.copen(output, 'w') as out:
        out.write(content)
1326531
def _file_write(path, content):
    '''
    
    '''
    with salt.utils.files.fopen(path, 'w+') as fp_:
        fp_.write(salt.utils.stringutils.to_str(content))
    fp_.close()
778923
def write_files(text, where='.'):
    """"""
    for filename in text:
        target = os.path.join(where, filename)
        write_file(target, text[filename])
704516
def write_dir_tree(self, tree):
        

        dirs  = tree['dirs']; files = tree['files']
        child_dirs = {name : self.write_dir_tree(contents) for name, contents in dirs.iteritems()}
        return self.write_index_object('tree', {'files' : files, 'dirs': child_dirs})
317367
def queue_files(dirpath, queue):
    """"""
    for root, _, files in os.walk(os.path.abspath(dirpath)):
        if not files:
            continue
        for filename in files:
            queue.put(os.path.join(root, filename))
801676
def writefile(openedfile, newcontents):
    """"""
    openedfile.seek(0)
    openedfile.truncate()
    openedfile.write(newcontents)
1098921
def write(file_name, data):
    """"""
    with open(file_name, 'w') as f:
        f.write(encode(data))
704279
def append_file_data(_dir, data)
      File.open(to_path, 'ab') { |file| file.write(data) }
    end
1171182
function writeFile (outDir, vars, file) {
  return function (done) {
    const fileName = file.path
    const inFile = file.fullPath
    const parentDir = file.parentDir
    const outFile = path.join(outDir, maxstache(removeUnderscore(fileName), vars))

    mkdirp(path.join(outDir, maxstache(parentDir, vars)), function (err) {
      if (err) return done(err)

      const rs = fs.createReadStream(inFile)
      const ts = maxstacheStream(vars)
      const ws = fs.createWriteStream(outFile)

      pump(rs, ts, ws, done)
    })
  }
}
272693
function writeToDisk(output, data, callback) {
  fs.mkdirp(path.dirname("" + output), function (err) {
    if (err) {
      if (callback) {
        callback(err);
      }
      return console.log(err);
    }
    fs.writeFile("" + output, data, function (err) {
      if (err) {
        if (callback) {
          callback(err);
        }
        return console.log(err);
      } else {
        if (callback) {
          callback();
        }
      }
    });
  });
}