Creates an internal representation of the destination file.

        This is where the thinking happens
760697
def _create_dest(self) -> None:
        
        in_body = False
        in_docstring = False
        in_copyright = False
        copyright_done = False
        docstring_done = False
        swallow_blanks_and_filename_in_docstring = False
        for linenum, sl in enumerate(self.source_lines, start=1):
            dl = sl

            if dl.endswith(SPACE):
                self._debug("Line {} ends in whitespace".format(linenum))
                dl = dl.rstrip()

            if not in_body:

                if linenum == 1:
                    # Shebang
                    if not dl.startswith(SHEBANG_START):
                        self._warn("File does not start with shebang; "
                                   "first line was {!r}".format(dl))
                        self._too_risky()
                        return
                    if dl != CORRECT_SHEBANG:
                        self._debug("Rewriting shebang; was {!r}".format(dl))
                    dl = CORRECT_SHEBANG

                if (linenum == 2 and dl.startswith(HASH_SPACE) and
                        dl.endswith(PYTHON_EXTENSION)):
                    self._debug(
                        "Removing filename comment: {!r}".format(dl))
                    dl = None

                elif TRIPLE_DOUBLEQUOTE in dl:
                    if (not dl.startswith(TRIPLE_DOUBLEQUOTE) and
                            not dl.startswith(RAW_TRIPLE_DOUBLEQUOTE)):
                        self._warn(
                            "Triple-quote not at start of line, as follows")
                        self._debug_line(linenum, dl)
                        self._too_risky()
                        return
                    if in_docstring:  # docstring finishing
                        in_docstring = False
                        docstring_done = True
                        in_body = True
                        # ... and keep dl, so we write the end of the
                        # docstring, potentially with e.g. "# noqa" on the end
                    elif not docstring_done:  # docstring starting
                        in_docstring = True
                        # self._critical("adding our new docstring")
                        # Write our new docstring's start
                        tdq = ""  # stops linter moaning
                        if dl.startswith(TRIPLE_DOUBLEQUOTE):
                            tdq = TRIPLE_DOUBLEQUOTE
                        elif dl.startswith(RAW_TRIPLE_DOUBLEQUOTE):
                            tdq = RAW_TRIPLE_DOUBLEQUOTE
                        else:
                            assert "Bug!"
                        self.dest_lines.append(tdq)
                        self.dest_lines.append(self.advertised_filename)
                        self.dest_lines.append(BLANK)
                        self.dest_lines.extend(self.correct_copyright_lines)
                        self.dest_lines.append(BLANK)
                        swallow_blanks_and_filename_in_docstring = True
                        if dl == tdq:
                            dl = None  # don't write another triple-quote line
                        else:
                            dl = dl[len(tdq):]

                elif in_docstring:
                    # Reading within the source docstring

                    if dl == TRANSITION:
                        if in_copyright:  # copyright finishing
                            in_copyright = False
                            copyright_done = True
                            dl = None  # we've already replaced with our own
                        elif not copyright_done:
                            in_copyright = True
                            dl = None  # we've already replaced with our own

                    elif in_copyright:
                        dl = None  # we've already replaced with our own

                    elif dl == RST_COMMENT_LINE:
                        dl = None  # remove these

                    elif swallow_blanks_and_filename_in_docstring:
                        # self._debug_line(linenum, dl)
                        if dl == BLANK or dl == self.advertised_filename:
                            dl = None
                        elif copyright_done:
                            swallow_blanks_and_filename_in_docstring = False

                elif not dl.startswith(HASH) and not dl == BLANK:
                    in_body = True

                    if not docstring_done:
                        # The source file didn't have a docstring!
                        new_docstring_lines = [
                            BLANK,
                            TRIPLE_DOUBLEQUOTE,
                            self.advertised_filename,
                            BLANK,
                        ] + self.correct_copyright_lines + [
                            BLANK,
                            MISSING_RST_TITLE,
                            BLANK,
                            TRIPLE_DOUBLEQUOTE
                        ]
                        self._warn("File had no docstring; adding one. "
                                   "Will need manual edit to add RST title. "
                                   "Search for {!r}".format(MISSING_RST_TITLE))
                        self.dest_lines[1:1] = new_docstring_lines

            if dl is not None:
                # self._debug_line(linenum, dl, "adding ")
                self.dest_lines.append(dl)

        self.needs_rewriting = self.dest_lines != self.source_lines
252789
public void writeNestedLibrary(String destination, Library library)
			throws IOException {
		File file = library.getFile();
		JarArchiveEntry entry = new JarArchiveEntry(destination + library.getName());
		entry.setTime(getNestedLibraryTime(file));
		new CrcAndSize(file).setupStoredEntry(entry);
		writeEntry(entry, new InputStreamEntryWriter(new FileInputStream(file), true),
				new LibraryUnpackHandler(library));
	}
1334541
def save_to(self, file):
        """"""
        dest = file

        if hasattr(dest, 'write'):
            # writing to a file-like
            # only works when no unicode conversion is done
            if self.file is not None and\
                    getattr(self.file, 'encoding', None) is None:
                copyfileobj(self.file, dest)
            elif self.filename is not None:
                with open(self.filename, 'rb') as inp:
                    copyfileobj(inp, dest)
            else:
                dest.write(self.__bytes__())
        else:
            # we do not use filesystem io to make sure we have the same
            # permissions all around
            # copyfileobj() should be efficient enough

            # destination is a filename
            with open(dest, 'wb') as out:
                return self.save_to(out)
285609
def create_textfile_with_contents(filename, contents, encoding='utf-8'):
    
    ensure_directory_exists(os.path.dirname(filename))
    if os.path.exists(filename):
        os.remove(filename)
    outstream = codecs.open(filename, "w", encoding)
    outstream.write(contents)
    if contents and not contents.endswith("\n"):
        outstream.write("\n")
    outstream.flush()
    outstream.close()
    assert os.path.exists(filename), "ENSURE file exists: %s" % filename
789650
def create_file(self, filename, indented_data=None):
        
        filedir, filename = os.path.split(filename)
        if filedir:
            self.create_directory(filedir)
        path = os.path.join(self.path, filedir, filename)
        data = indented_data
        if isinstance(data, bytes) and not isinstance(data, str):
            # This is binary data rather than text.
            mode = 'wb'
        else:
            mode = 'w'
            if data:
                data = textwrap.dedent(data)
        with open(path, mode) as fi:
            if data:
                fi.write(data)
        return path
197630
function processDestination(destination) {
    var destinations = [];

    if (_.isArray(destination)) {
      destinations = destination;
    }
    if (_.isString(destination)) {
      destinations.push(destination);
    }
    if (!destinations.length) {
      throw new Error('Destination file not defined.');
    }
    return destinations.map(util.resolveEnsureFile);
  }
1123867
private void writeOnDisk(JSONObject plistJSON, File destination)
      throws IOException, JSONException {
    if (destination.exists()) {
      // This is possible if we start with capability "reuseContentAndSettings"
      log.info(destination + " already exists. Overwriting data");
    }

    // make sure the folder is ready for the plist file
    destination.getParentFile().mkdirs();

    checkPlUtil();

    File from = createTmpFile(plistJSON);

    List<String> command = new ArrayList<>();
    command.add(PLUTIL);
    command.add("-convert");
    command.add("binary1");
    command.add("-o");
    command.add(destination.getAbsolutePath());
    command.add(from.getAbsolutePath());

    ProcessBuilder b = new ProcessBuilder(command);
    int i;
    try {
      Process p = b.start();
      i = p.waitFor();
    } catch (Exception e) {
      throw new WebDriverException("failed to run " + command.toString(), e);
    }
    if (i != 0) {
      throw new WebDriverException("conversion to binary plist failed. exitCode=" + i);
    }
  }
310084
def _make_destination_callable(dest):
    
    if callable(dest):
        return dest
    elif hasattr(dest, 'write') or isinstance(dest, string_types):
        return _use_filehandle_to_save(dest)
    else:
        raise TypeError("Destination must be a string, writable or callable object.")
294240
def create_file(self, fileName, contents=""):
        
        with open(fileName, "w") as written_file:
            written_file.write(contents)
972915
def copy(source, destination):
    
    source = os.path.abspath(source)
    destination = os.path.abspath(destination)
    if source != destination:
        if not os.path.exists(os.path.dirname(destination)):
            os.makedirs(os.path.dirname(destination))
        shutil.copyfile(source, destination)
1231767
public void process() {
    if (src == null && dest == null) {
      throw new IllegalArgumentException("Source and destination shouldn't be null together");
    }

    File destinationFile = null;
    try {
      destinationFile = getDestinationFile();
      ZipOutputStream out = null;
      ZipEntryOrInfoAdapter zipEntryAdapter = null;

      if (destinationFile.isFile()) {
        out = ZipFileUtil.createZipOutputStream(new BufferedOutputStream(new FileOutputStream(destinationFile)), charset);
        zipEntryAdapter = new ZipEntryOrInfoAdapter(new CopyingCallback(transformers, out, preserveTimestamps), null);
      }
      else { // directory
        zipEntryAdapter = new ZipEntryOrInfoAdapter(new UnpackingCallback(transformers, destinationFile), null);
      }
      try {
        processAllEntries(zipEntryAdapter);
      }
      finally {
        IOUtils.closeQuietly(out);
      }
        handleInPlaceActions(destinationFile);
    }
    catch (IOException e) {
      ZipExceptionUtil.rethrow(e);
    }
    finally {
      if (isInPlace()) {
        // destinationZip is a temporary file
        FileUtils.deleteQuietly(destinationFile);
      }
    }
  }
20615
def integrate_to_file(what, filename, start_line, end_line):
    

    try:
        with open(filename) as f:
            lines = f.readlines()
    except IOError:
        lines = []

    tmp_file = tempfile.NamedTemporaryFile(delete=False)

    lines.reverse()

    # first copy before start line
    while lines:
        line = lines.pop()

        if line == start_line:
            break

        tmp_file.write(line)

    # insert content
    tmp_file.write(start_line)
    tmp_file.write(what)
    tmp_file.write(end_line)

    # skip until end line
    while lines:
        line = lines.pop()

        if line == end_line:
            break

    # copy rest
    tmp_file.writelines(lines)
    tmp_file.close()

    os.rename(tmp_file.name, filename)
1142422
def copy_contents_to(self, destination):
        
        logger.info("Copying contents of %s to %s" % (self, destination))
        target = Folder(destination)
        target.make()
        self._create_target_tree(target)
        dir_util.copy_tree(self.path, unicode(target))
        return target
192707
def write_files(template, destination='./dxf'):
    
    os.makedirs(destination)
    for key, value in template.items():
        with open(os.path.join(destination, key), 'w') as f:
            f.write(replace_whitespace(value, insert=False))
1354521
private void createOutputFile() throws IOException {
        this.fileChannel = Files.newByteChannel(Paths.get(filePath), StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);
    }
1255364
@Override
	public FSDataOutputStream create(Path f, WriteMode overwriteMode) throws IOException {
		return createOutputStream(() -> originalFs.create(f, overwriteMode));
	}
55179
def put_file(self):
        """"""
        destination = "{}/{}".format(self.file_system, self.dest_file)
        self.scp_conn.scp_transfer_file(self.source_file, destination)
        # Must close the SCP connection to get the file written (flush)
        self.scp_conn.close()