Regenerate (or generate) a file, either from source file or from output file
184584
def regenerateFile(srcFile, pathComponents, sourceType, makeBackup)
      #puts "regenerateFile, srcFile = #{srcFile}, sourceType = #{sourceType.inspect}"
      outFile = File.join(@sourceTypeDirs[@oppositeSourceType[sourceType]], File.join(pathComponents))
      #puts " outFile = #{outFile}"
      outFileDir = File.dirname(outFile)
      if !File.exists?(outFileDir)
        if sourceType == :output
          raise "Cannot create missing source directory #{outFileDir} - please do so manually if required"
        end
        ensureDirectoryExists(outFileDir)
      end
      if sourceType == :output
        regenerateSourceFromOutput(srcFile, pathComponents)
      elsif sourceType == :source
        regenerateFileFromSource(srcFile, pathComponents, makeBackup)
      end
    end
469003
def run(self) -> Generator[Tuple[int, int, str, type], None, None]:
        
        if self.filename != STDIN:
            buffer = StringIO()
            options = _Options(aggressive=self.options.eradicate_aggressive)
            fix_file(self.filename, options, buffer)
            traceback = buffer.getvalue()

            if traceback:
                yield 1, 0, self._error(traceback), type(self)
1282294
function fileToOutput(output, filePath) {
    var book = output.getBook();
    var readme = book.getReadme();
    var fileReadme = readme.getFile();

    if (
        path.basename(filePath, path.extname(filePath)) == 'README' ||
        (fileReadme.exists() && filePath == fileReadme.getPath())
    ) {
        filePath = path.join(path.dirname(filePath), 'index' + OUTPUT_EXTENSION);
    } else {
        filePath = PathUtils.setExtension(filePath, OUTPUT_EXTENSION);
    }

    return LocationUtils.normalize(filePath);
}
550031
def gen_template_files(path):
    "  "

    path = path.rstrip(op.sep)
    for root, _, files in walk(path):
        for f in filter(lambda x: not x in (TPLNAME, CFGNAME), files):
            yield op.relpath(op.join(root, f), path)
145663
def main(argv):
    
    init()

    if OPTIONS.StdErrFileName.value:
        OPTIONS.stderr.value = open('wt', OPTIONS.StdErrFileName.value)

    asmlex.FILENAME = OPTIONS.inputFileName.value = argv[0]
    input_ = open(OPTIONS.inputFileName.value, 'rt').read()
    assemble(input_)
    generate_binary(OPTIONS.outputFileName.value, OPTIONS.output_file_type)
1032096
def reload(script, input, output):
    
    script = Path(script).expand().abspath()
    output = Path(output).expand().abspath()
    input = input if isinstance(input, (list, tuple)) else [input]
    output.makedirs_p()
    _script_reload(script, input, output)
24418
function (filepath, options, callback) {
        if (typeof options === 'function') {
            callback = options;
            options = undefined;
        }

        options = options || '';
        var args = _.compact([filepath].concat(options.replace(/\ \ /g, ' ').split(' ')));

        logger.debug('cmd:', constant.PROG_OPTIPNG, args.join(' '));

        var proc = spawn(constant.PROG_OPTIPNG, args);

        proc.stdout.on('data', function (data) {
            logger.debug(data.toString());
        });

        proc.stderr.on('data', function (data) {
            logger.debug(data.toString());
        });

        proc.addListener('exit', function (e) {
            if (e) {
                return callback(e);
            }
            callback();
        });
    }
884016
def generate(env):
   
   doxyfile_scanner = env.Scanner(
      DoxySourceScan,
      "DoxySourceScan",
      scan_check = DoxySourceScanCheck,
   )

   import SCons.Builder
   doxyfile_builder = SCons.Builder.Builder(
      action = "cd ${SOURCE.dir}  &&  ${DOXYGEN} ${SOURCE.file}",
      emitter = DoxyEmitter,
      target_factory = env.fs.Entry,
      single_source = True,
      source_scanner =  doxyfile_scanner,
   )

   env.Append(BUILDERS = {
      'Doxygen': doxyfile_builder,
   })

   env.AppendUnique(
      DOXYGEN = 'doxygen',
   )
1075382
def file_adapter(file_or_path):
    """"""
    if is_file(file_or_path):
        file_obj = file_or_path
    else:
        file_obj = open(file_or_path, 'rb')
    yield file_obj
    file_obj.close()
90251
def create(client, output_file, revision, paths):
    """"""
    graph = Graph(client)
    outputs = graph.build(paths=paths, revision=revision)

    output_file.write(
        yaml.dump(
            ascwl(
                graph.ascwl(outputs=outputs),
                filter=lambda _, x: x is not None and x != [],
                basedir=os.path.dirname(getattr(output_file, 'name', '.')) or
                '.',
            ),
            default_flow_style=False
        )
    )
1302210
def _copy_or_render_source(ext, f, output_dir, render_callback,
                           skip_copy=False):
    
    # Either render a template or copy the source
    dirname = os.path.dirname(f)
    filename = os.path.basename(f)
    for pattern, target, subsd in ext.template_regexps:
        if re.match(pattern, filename):
            tgt = os.path.join(dirname, re.sub(
                pattern, target, filename))
            rw = MetaReaderWriter('.metadata_subsd')
            try:
                prev_subsd = rw.get_from_metadata_file(output_dir, f)
            except (FileNotFoundError, KeyError):
                prev_subsd = None

            render_callback(
                get_abspath(f),
                os.path.join(output_dir, tgt),
                subsd,
                only_update=ext.only_update,
                prev_subsd=prev_subsd,
                create_dest_dirs=True,
                logger=ext.logger)
            rw.save_to_metadata_file(output_dir, f, subsd)
            return tgt
    else:
        if not skip_copy:
            copy(f,
                 os.path.join(output_dir,
                              os.path.dirname(f)),
                 only_update=ext.only_update,
                 dest_is_dir=True,
                 create_dest_dirs=True,
                 logger=ext.logger)
        return f
1121281
public final void generate(Resource input, IFileSystemAccess2 fsa, IGeneratorContext context) {
		try {
			beforeGenerate(input, fsa, context);
			doGenerate(input, fsa, context);
		} finally {
			afterGenerate(input, fsa, context);
		}
	}
1345753
def generate(self):
        
        if self._tar_buffer.tell():
            self._tar_buffer.seek(0, 0)
            yield self._tar_buffer.read()

        for fname in self._files_to_add:
            last = self._tar_buffer.tell()
            self._tar_obj.add(fname)
            self._tar_buffer.seek(last, os.SEEK_SET)
            data = self._tar_buffer.read()
            yield data

        for info, content in self._ios_to_add.items():
            last = self._tar_buffer.tell()
            self._tar_obj.addfile(info, content)
            self._tar_buffer.seek(last, os.SEEK_SET)
            data = self._tar_buffer.read()
            yield data

        self._tar_obj.close()
        yield self._tar_buffer.read()
        self._generated = True
570061
def output_file(self, _container):
        """"""
        p = local.path(_container)
        if p.exists():
            if not ui.ask("Path '{0}' already exists."
                          " Overwrite?".format(p)):
                sys.exit(0)
        CFG["container"]["output"] = str(p)
334720
def writeRegeneratedFile(outFile, makeBackup, checkNoChanges)
      puts "writeRegeneratedFile, #{outFile}, makeBackup = #{makeBackup}, checkNoChanges = #{checkNoChanges}"
      if makeBackup
        backupFileName = makeBackupFile(outFile)
      end
      File.open(outFile, "w") do |f|
        for component in @components do
          f.write(component.output)
        end
      end
      puts " wrote regenerated page to #{outFile}"
      if checkNoChanges
        if !makeBackup
          raise Exception.new("writeRegeneratedFile #{outFile}: checkNoChanges specified, but no backup was made")
        end
        checkAndEnsureOutputFileUnchanged(outFile, backupFileName)
      end
    end
217647
def _generate(self):
        

        needs_close = False

        if sys.hexversion >= 0x03000000:
            if self._opts.output == '-':
                from io import TextIOWrapper

                pyfile = TextIOWrapper(sys.stdout.buffer, encoding='utf8')
            else:
                pyfile = open(self._opts.output, 'wt', encoding='utf8')
                needs_close = True
        else:
            if self._opts.output == '-':
                pyfile = sys.stdout
            else:
                pyfile = open(self._opts.output, 'wt')
                needs_close = True

        import_from = self._opts.import_from

        if import_from:
            from_imports = True
        elif self._opts.from_imports:
            from_imports = True
            import_from = '.'
        else:
            from_imports = False

        compileUi(self._ui_file, pyfile, self._opts.execute, self._opts.indent,
                from_imports, self._opts.resource_suffix, import_from)

        if needs_close:
            pyfile.close()
508183
def FromFile(cls, filename, overwrite=False, auto_transfer=True, **kwds):
        """"""
        path = os.path.expanduser(filename)
        if os.path.exists(path) and not overwrite:
            raise exceptions.InvalidUserInputError(
                'File %s exists and overwrite not specified' % path)
        return cls(open(path, 'wb'), close_stream=True,
                   auto_transfer=auto_transfer, **kwds)