Writes to an output file if `outfile` is a valid path.
555215
def output_markdown(markdown_cont, output_file):
    
    if output_file:
        with open(output_file, 'w') as out:
            out.write(markdown_cont)
742173
def write_out(path = nil)
      return img unless path
      FileUtils.mkdir_p File.dirname(path)
      img.write(path)
      path
    rescue Errno::ENOENT
      puts_and_exit("Path not found '#{path}'")
    end
198661
def output(self):
        
        if not self.path_output:
            self.output_to_fd(sys.stdout)
        else:
            with open(self.path_output, "w") as out:
                self.output_to_fd(out)
1105175
public void writeTo(Path directory) throws IOException {
    checkArgument(Files.notExists(directory) || Files.isDirectory(directory),
        "path %s exists but is not a directory.", directory);
    Path outputDirectory = directory;
    if (!packageName.isEmpty()) {
      for (String packageComponent : packageName.split("\\.")) {
        outputDirectory = outputDirectory.resolve(packageComponent);
      }
      Files.createDirectories(outputDirectory);
    }

    Path outputPath = outputDirectory.resolve(typeSpec.name + ".java");
    try (Writer writer = new OutputStreamWriter(Files.newOutputStream(outputPath), UTF_8)) {
      writeTo(writer);
    }
  }
1065011
def copy_file(self, infile, outfile, check=True):
        
        self.ensure_dir(os.path.dirname(outfile))
        logger.info('Copying %s to %s', infile, outfile)
        if not self.dry_run:
            msg = None
            if check:
                if os.path.islink(outfile):
                    msg = '%s is a symlink' % outfile
                elif os.path.exists(outfile) and not os.path.isfile(outfile):
                    msg = '%s is a non-regular file' % outfile
            if msg:
                raise ValueError(msg + ' which would be overwritten')
            shutil.copyfile(infile, outfile)
        self.record_as_written(outfile)
1241083
private void output(File outFile) throws FileNotFoundException {
    System.out.println("Printing to " + outFile.toString());
    PrintStream out = new PrintStream(outFile);
    root.output(out, null);
    out.close();
  }
908679
private void validateOutputPath(final File path) {
        if (path.canWrite()) return;

        // If the path doesn't exist...
        if (!path.exists()) {
            // ... try creating it...
            if (!path.mkdirs()) {
                // ... or die trying.
                String err = DIRECTORY_CREATION_FAILED.concat(path.toString());
                throw new BELRuntimeException(err, UNRECOVERABLE_ERROR);
            }
            return;
        }

        // ... can't write to it.
        String err = CANT_WRITE_TO_PATH.concat(path.toString());
        throw new BELRuntimeException(err, UNRECOVERABLE_ERROR);
    }
840345
def write_output(output, text=True, output_path=None):
    """"""

    if output_path is None and text is False:
        print("ERROR: You must specify an output file using -o/--output for binary output formats")
        sys.exit(1)

    if output_path is not None:
        if text:
            outfile = open(output_path, "w", encoding="utf-8")
        else:
            outfile = open(output_path, "wb")
    else:
        outfile = sys.stdout

    try:
        if text and isinstance(output, bytes):
            output = output.decode('utf-8')

        outfile.write(output)
    finally:
        if outfile is not sys.stdout:
            outfile.close()
851099
def validate_file(parser, arg):
    """"""
    if not os.path.isfile(arg):
        parser.error("%s is not a file." % arg)
    return arg
1302474
def is_valid_file(path):
    '''  '''
    return os.path.exists(path) and os.path.isfile(path)
1022550
protected function ensureFileIsWritable()
    {
        if ((!is_writable($this->filePath) || !is_file($this->filePath))
            && (!is_dir(dirname($this->filePath)) || !is_writable(dirname($this->filePath)))
        ) {
            throw new InvalidPathException(sprintf('Unable to write the environment file at %s.', $this->filePath));
        }
    }
515172
function writeFile (file, callback) {
  fs.outputFile(path.resolve(this._destination, path.join(file.path.dir, file.path.name + file.path.ext)), file.content, function (err) {
    if (err) callback(err);
    callback(null);
  });
}
1038979
def write(self):
        '''
        '''
        if not self.output_files.valid():
            raise ValueError(
                f'Cannot write signature with undetermined output {self.output_files}'
            )
        else:
            if 'TARGET' in env.config['SOS_DEBUG'] or 'ALL' in env.config['SOS_DEBUG']:
                env.log_to_file(
                    'TARGET',
                    f'write signature {self.sig_id} with output {self.output_files}'
                )
        ret = super(RuntimeInfo, self).write()
        if ret is False:
            env.logger.debug(f'Failed to write signature {self.sig_id}')
            return ret
        send_message_to_controller(['step_sig', self.sig_id, ret])
        send_message_to_controller([
            'workflow_sig', 'tracked_files', self.sig_id,
            repr({
                'input_files': [
                    str(f.resolve())
                    for f in self.input_files
                    if isinstance(f, file_target)
                ],
                'dependent_files': [
                    str(f.resolve())
                    for f in self.dependent_files
                    if isinstance(f, file_target)
                ],
                'output_files': [
                    str(f.resolve())
                    for f in self.output_files
                    if isinstance(f, file_target)
                ]
            })
        ])
        return True
315917
function (files, output, name) {
    this.files = files;
    this.outputfile = path.resolve(output || os.tmpdir()) + path.sep + (name || '.check');
    this.data = {};
}
1367584
private function writelnSkipFile(OutputInterface $output, $pathFile, $file_type = null)
    {
        $file_type = $file_type === null ? '' : sprintf("%s ", $file_type);

        $output->writeln(
            sprintf(
                " <fg=red>✗</fg=red>  <fg=blue>Preserving</fg=blue> existing %sfile <fg=yellow>'%s'</fg=yellow>.",
                $file_type,
                $pathFile
            )
        );
    }
315597
function writeOutput(filePath, content, failOnError, cb) {
    var outStream;
    if (!filePath) {
        if (content) {
            console.log(content);
        }
        if (failOnError) {
            return cb(new gutil.PluginError('gulp-jscs-custom', 'JSCS validation failed', {
                showStack: false
            }));
        } else {
            return cb();
        }
    }
    outStream = fs.createWriteStream(filePath);
    outStream.write(content, null, cb);
}
999008
def is_writable(path):
    """"""
    try:
        testfile = tempfile.TemporaryFile(dir=path)
        testfile.close()
    except OSError as e:
        if e.errno == errno.EACCES:  # 13
            return False
    return True