Instead of duplicating files, it is much more efficient to create the itterator on the fly
185778
def allfiles(self):
        
        for f in self.files:
            yield f
        for f in self.extra_files:
            yield f
848104
function dup(x) {
    var i, buff;
    buff=new Array(x.length);
    copy_(buff,x);
    return buff;
  }
520205
def _make_io_iterator(handle):
    """"""
    name = ctypes.c_char_p()
    desc = ctypes.c_char_p()
    num_args = mx_uint()
    arg_names = ctypes.POINTER(ctypes.c_char_p)()
    arg_types = ctypes.POINTER(ctypes.c_char_p)()
    arg_descs = ctypes.POINTER(ctypes.c_char_p)()

    check_call(_LIB.MXDataIterGetIterInfo( \
            handle, ctypes.byref(name), ctypes.byref(desc), \
            ctypes.byref(num_args), \
            ctypes.byref(arg_names), \
            ctypes.byref(arg_types), \
            ctypes.byref(arg_descs)))
    iter_name = py_str(name.value)

    narg = int(num_args.value)
    param_str = _build_param_doc(
        [py_str(arg_names[i]) for i in range(narg)],
        [py_str(arg_types[i]) for i in range(narg)],
        [py_str(arg_descs[i]) for i in range(narg)])

    doc_str = ('%s\n\n' +
               '%s\n' +
               'Returns\n' +
               '-------\n' +
               'MXDataIter\n'+
               '    The result iterator.')
    doc_str = doc_str % (desc.value, param_str)

    def creator(*args, **kwargs):
        """Create an iterator.
        The parameters listed below can be passed in as keyword arguments.

        Parameters
        ----------
        name : string, required.
            Name of the resulting data iterator.

        Returns
        -------
        dataiter: Dataiter
            The resulting data iterator.
        """
        param_keys = []
        param_vals = []

        for k, val in kwargs.items():
            param_keys.append(k)
            param_vals.append(str(val))
        # create atomic symbol
        param_keys = c_str_array(param_keys)
        param_vals = c_str_array(param_vals)
        iter_handle = DataIterHandle()
        check_call(_LIB.MXDataIterCreateIter(
            handle,
            mx_uint(len(param_keys)),
            param_keys, param_vals,
            ctypes.byref(iter_handle)))

        if len(args):
            raise TypeError('%s can only accept keyword arguments' % iter_name)

        return MXDataIter(iter_handle, **kwargs)

    creator.__name__ = iter_name
    creator.__doc__ = doc_str
    return creator
13610
def recursive_generate_copy_in(copy_in, current_path)
      limited_files_of(current_path) { |file| copy_in << file }
      directories_of(current_path) do |dir|
        recursive_generate_copy_in(copy_in, ::File.join(dir))
      end
      true
    end
915179
function createNewFileByContents(file, newContents) {

  var newFile = file.clone()

  newFile.contents = newContents

  return newFile
}
379932
function copyFile (src, dest, ncpOpts, callback) {
  var orchestrator = new Orchestrator();
  var parts = dest.split(path.sep);
  var fileName = parts.pop();
  var destDir = parts.join(path.sep);
  var destFile = path.resolve(destDir, fileName);
  orchestrator.add('ensureDir', function (done) {
    mkdirp(destDir, function (err) {
      done(err);
    });
  });
  orchestrator.add('copyFile', ['ensureDir'], function (done) {
    ncp(src, destFile, ncpOpts, function (err) {
      done(err);
    });
  });
  orchestrator.start('copyFile', function (err) {
    callback(err);
  });
}
607925
@GwtIncompatible("Unnecessary")
  private ImmutableList<JSError> deduplicateIjsFiles(
      List<FlagEntry<JsSourceType>> files, List<String> moduleRoots, boolean hasModuleSpecs) {
    ImmutableList.Builder<JSError> errors = ImmutableList.builder();

    // First pass: collect the (module root relative) names of --js and --weakdep files.
    Map<String, String> relativeToAbsoluteName = new HashMap<>();
    for (FlagEntry<JsSourceType> file : files) {
      // TODO(tjgq): Handle zip files.
      if (file.flag == JsSourceType.JS || file.flag == JsSourceType.WEAKDEP) {
        String absoluteName = file.value;
        String relativeName = getModuleRootRelativeName(absoluteName, moduleRoots);
        relativeToAbsoluteName.put(relativeName, absoluteName);
      }
    }

    // Second pass: drop --ijs files whose (module root relative) name matches a --js or --weakdep
    // file.
    Iterator<FlagEntry<JsSourceType>> iterator = files.iterator();
    while (iterator.hasNext()) {
      FlagEntry<JsSourceType> file = iterator.next();
      if (file.flag == JsSourceType.IJS) {
        if (hasModuleSpecs) {
          throw new FlagUsageException("--ijs is incompatible with --chunk or --module.");
        }
        String absoluteName = file.value;
        if (!absoluteName.endsWith(".i.js")) {
          errors.add(JSError.make(IjsErrors.BAD_IJS_FILE_NAME, absoluteName));
          continue;
        }
        String relativeName = getModuleRootRelativeName(absoluteName, moduleRoots);
        String relativeNonIjsName =
            relativeName.substring(0, relativeName.length() - ".i.js".length());
        if (relativeToAbsoluteName.containsKey(relativeNonIjsName)) {
          errors.add(
              JSError.make(
                  IjsErrors.CONFLICTING_IJS_FILE,
                  relativeToAbsoluteName.get(relativeNonIjsName),
                  absoluteName));
          iterator.remove();
        }
      }
    }

    return errors.build();
  }
1022102
function copyReplace( src, dest, replacements ){

        if ( replacements ){
            var source = grunt.file.read( src );
            for ( var s in replacements ){
                var r = replacements[s];
                var re = new RegExp( s, "g" );
                source = source.replace( re, r );
            }
            grunt.file.write( dest, source );
        }
        else{
            grunt.file.copy( src, dest );
        }

	}
770303
function copy(finished) {
    fs.createReadStream(infile)
      .once('error', callback)
      .pipe(fs.createWriteStream(outfile))
      .once('error', callback)
      .on('finish', finished);
  }
1080574
def generate(self, overwrite=False):
        
        super(Upstart, self).generate(overwrite=overwrite)

        svc_file_template = self.template_prefix + '.conf'
        self.svc_file_path = self.generate_into_prefix + '.conf'

        self.generate_file_from_template(svc_file_template, self.svc_file_path)
        return self.files
1200654
def _clone_file_everywhere(self, finfo):
        """"""
        for editorstack in self.editorstacks[1:]:
            editor = editorstack.clone_editor_from(finfo, set_current=False)
            self.register_widget_shortcuts(editor)
1245845
def filesessionmaker(sessionmaker, file_manager, file_managers=None):
    
    '''

    registry = WeakKeyDictionary()

    if file_managers:
        for k, v in six.iteritems(file_managers):
            if isinstance(k, FileAttribute):
                raise NotImplementedError()
            registry[k] = v

    def find_file_manager(self, target):
        if isinstance(target, FileAttribute):
            assert hasattr(target, 'class_')
            target = target.class_
        else:
            if not inspect.isclass(target):
                target = type(target)

        assert hasattr(target, 'metadata')
        assert class_mapper(target) is not None
        if target in registry:
            return registry[target]
        if target.metadata in registry:
            return registry[target.metadata]
        return file_manager

    def session_maker(*args, **kwargs):
        session = sessionmaker(*args, **kwargs)
        # XXX in case we want to use session manager somehow bound 
        #     to request environment. For example, to generate user-specific
        #     URLs.
        #session.file_manager = \
        #        kwargs.get('file_manager', file_manager)
        session.file_manager = file_manager
        session.find_file_manager = six.create_bound_method(
                                            find_file_manager,
                                            session)

        return session
    return session_maker
503608
function () {

    var done = this.async();

    if(this.createMode) {

      // copy yoga-generator itself
      this.fs.copy(path.join(__dirname, '../'), this.destinationPath(), {
        globOptions: {
          dot: true,
          ignore: [
            '**/.DS_Store',
            '**/.git',
            '**/.git/**/*',
            '**/node_modules',
            '**/node_modules/**/*',
            '**/test/**/*',
            '**/create/**/*'
          ]
        }
      })

      // copy the package.json and README
      this.fs.copyTpl(path.join(__dirname, '../create/{}package.json'), this.destinationPath('package.json'), this.viewData)

      this.fs.copyTpl(path.join(__dirname, '../create/README.md'), this.destinationPath('README.md'), this.viewData)

      done()
    }
    else {
      this.registerTransformStream(striate(this.viewData))

      prefixnote.parseFiles(this.templatePath(), this.viewData)

        // copy each file that is traversed
        .on('data', function (file) {
          var filename = path.basename(file.original)

          // always ignore files like .DS_Store
          if(ignore.indexOf(filename) === -1) {
            var from = file.original
            var to = this.destinationPath(path.relative(this.templatePath(), file.parsed))

            // copy the file with templating
            this.fs.copyTpl(from, to, this.viewData)
          }
        }.bind(this))

        .on('end', done)
        .on('error', done)
    }
  }
1256636
def merge_replacement_files(tmpdir, mergefile):
  """"""
  # The fixes suggested by clang-tidy >= 4.0.0 are given under
  # the top level key 'Diagnostics' in the output yaml files
  mergekey="Diagnostics"
  merged=[]
  for replacefile in glob.iglob(os.path.join(tmpdir, '*.yaml')):
    content = yaml.safe_load(open(replacefile, 'r'))
    if not content:
      continue # Skip empty files.
    merged.extend(content.get(mergekey, []))

  if merged:
    # MainSourceFile: The key is required by the definition inside
    # include/clang/Tooling/ReplacementsYaml.h, but the value
    # is actually never used inside clang-apply-replacements,
    # so we set it to '' here.
    output = { 'MainSourceFile': '', mergekey: merged }
    with open(mergefile, 'w') as out:
      yaml.safe_dump(output, out)
  else:
    # Empty the file:
    open(mergefile, 'w').close()
240327
function createBundler(opts, file, transform) {
  // omit file contents to make browserify-incremental work propery
  // on main entry (#4)
  opts.entries = file.path
  opts.basedir = path.dirname(file.path)

  let bundler = bundlers[file.path]

  if (bundler) {
    bundler.removeAllListeners('log')
    bundler.removeAllListeners('time')
  }
  else {
    bundler = browserify(Object.assign(opts, incremental.args))
    // only available via method call (#25)
    if (opts.external) {
      bundler.external(opts.external)
    }
    incremental(bundler)
    bundlers[file.path] = bundler
  }

  bundler.on('log', message => transform.emit('log', message))
  bundler.on('time', time => transform.emit('time', time))

  return bundler
}
424640
def buildFileList(input, output=None, ivmlist=None,
                wcskey=None, updatewcs=True, **workinplace):
    
    newfilelist, ivmlist, output, oldasndict, filelist = \
        buildFileListOrig(input=input, output=output, ivmlist=ivmlist,
                    wcskey=wcskey, updatewcs=updatewcs, **workinplace)
    return newfilelist, ivmlist, output, oldasndict
709709
function copyFiles(sourceDir, files, options = {}) {
	const { overwrite = true, errorOnExist } = options;

	_.castArray(files).forEach(file => {
		const sourcePath = path.resolve(sourceDir, file);
		if (!fs.existsSync(sourcePath)) {
			throw new MrmError(`copyFiles: source file not found: ${sourcePath}`);
		}

		const targetExist = fs.existsSync(file);
		if (targetExist && !overwrite) {
			if (errorOnExist) {
				throw new MrmError(`copyFiles: target file already exists: ${file}`);
			}
			return;
		}

		const content = read(sourcePath);

		// Skip copy if file contents are the same
		if (content === read(file)) {
			return;
		}

		updateFile(file, content, targetExist);
	});
}