Copy object of the same storage.

        Args:
            src (str): Path or URL.
            dst (str): Path or URL.
            other_system (pycosio._core.io_system.SystemBase subclass): Unused.
504720
def copy(self, src, dst, other_system=None):
        
        copy_source = self.get_client_kwargs(src)
        copy_destination = self.get_client_kwargs(dst)
        with _handle_oss_error():
            bucket = self._get_bucket(copy_destination)
            bucket.copy_object(
                source_bucket_name=copy_source['bucket_name'],
                source_key=copy_source['key'],
                target_key=copy_destination['key'])
1054114
def _copy(src, dst):
    """"""
    try:
        shutil.copy(src, dst)
    except IsADirectoryError:
        if os.path.isdir(dst):
            dst = os.path.join(dst, os.path.basename(src))
        shutil.copytree(src, dst)
404242
def cp(src, dst):
    
    print("[DEBUG]:   -> copying {} to {}".format(src, dst))
    if os.path.isfile(src):
        if not exists(dirname(dst)):
            os.makedirs(dirname(dst))
        shutil.copy(src, dst)
    else:
        copy_tree(src, dst)
853598
private void copyFromLocal(Path srcDir, Path dst) throws IOException {
    long partSize = conf.getLong(HAR_PARTSIZE_LABEL, HAR_PARTSIZE_DEFAULT);
    
    FileSystem srcFS = FileSystem.getLocal(conf);
    int partId = 0;
    FSDataOutputStream partStream = null;
    
    // index entries will be sorted by hash
    TreeMap<Integer, String> indexEntries = new TreeMap<Integer, String>();
    Queue<LocalAndArchivePaths> queue = new LinkedList<LocalAndArchivePaths>();
 
    try {
      queue.add(new LocalAndArchivePaths(srcDir, Path.SEPARATOR));
      while (!queue.isEmpty()) {
        LocalAndArchivePaths item = queue.remove();
        Path localPath = item.getLocalPath();
        String archiveItem = item.getArchivePath();

        FileStatus currenPathFileStatus = srcFS.getFileStatus(localPath);

        StringBuilder toWrite = new StringBuilder(
            URLEncoder.encode(item.getArchivePath().toString(), "UTF-8"));

        String properties = new HarProperties(currenPathFileStatus).serialize();

        if (currenPathFileStatus.isDir()) {
          FileStatus chlids[] = srcFS.listStatus(localPath);
          toWrite.append(" dir ");
          toWrite.append(properties);
          toWrite.append(" 0 0");
          for (FileStatus child : chlids) {
            Path childPath = child.getPath();
            String nextArchiveItem = new Path(archiveItem, childPath.getName()).toString(); 
            queue.add(new LocalAndArchivePaths(childPath, nextArchiveItem));
            toWrite.append(" ");
            toWrite.append(URLEncoder.encode(childPath.getName().toString(), "UTF-8"));
          }
          toWrite.append("\n");
        } else {
          if (partStream == null) {
            partStream = createNewPartStream(dst, partId);
          }

          toWrite.append(" file ");
          toWrite.append("part-" + partId);
          toWrite.append(" ");
          toWrite.append(partStream.getPos() + " " + currenPathFileStatus.getLen());
          toWrite.append(" " + properties);
          toWrite.append("\n");

          InputStream input = srcFS.open(localPath);
          IOUtils.copyBytes(input, partStream, conf, false);

          // proceed to next part
          if (partStream.getPos() >= partSize) {
            ++partId;
            partStream.close();
            partStream = null;
          }
        }
        int hash = HarFileSystem.getHarHash(archiveItem);
        indexEntries.put(new Integer(hash), toWrite.toString());
      }
    } finally {
      if (partStream != null) {
        partStream.close();
      }
    }

    // Now create master index
    // IndexEntries are already sorted by hash
    Path index = new Path(dst, HarFileSystem.INDEX_NAME);
    Path masterIndex = new Path(dst, HarFileSystem.MASTER_INDEX_NAME);
    
    FSDataOutputStream indexStream = null;
    FSDataOutputStream masterIndexStream = null;
    
    try {
      FileSystem dstFS = index.getFileSystem(conf);
      indexStream = dstFS.create(index);
      masterIndexStream = dstFS.create(masterIndex);
      String version = VERSION + "\n";
      masterIndexStream.write(version.getBytes());

      int startHash = 0;
      int endHash = 0;
      long indexStartPos = 0;
      long indexEndPos = 0;
      long numLines = 0;
      for (Map.Entry<Integer, String> indexEntry : indexEntries.entrySet()) {
        if (numLines == 0) {
          startHash = indexEntry.getKey();
          indexStartPos = indexStream.getPos();
        }
        endHash = indexEntry.getKey();
        indexStream.write(indexEntry.getValue().getBytes());
        ++numLines;
        if (numLines >= HadoopArchives.NUM_LINES_IN_BLOCK_INDEX) {
          numLines = 0;
          indexEndPos = indexStream.getPos();
          writeLineToMasterIndex(masterIndexStream, startHash, endHash, indexStartPos, indexEndPos);
        }
      }

      if (numLines > 0) {
        numLines = 0;
        indexEndPos = indexStream.getPos();
        writeLineToMasterIndex(masterIndexStream, startHash, endHash, indexStartPos, indexEndPos);
      }

    } finally {
      if (indexStream != null) {
        indexStream.close();
      }

      if (masterIndexStream != null) {
        masterIndexStream.close();
      }
    }
  }
936674
private function __copyDir($src, $dst, &$files = null)
    {
        $dir = opendir($src);
        @mkdir($dst);
        while (false !== ($file = readdir($dir))) {
            if (('.' != $file) && ('..' != $file)) {
                if (is_dir($src.'/'.$file)) {
                    $this->__copyDir($src.'/'.$file, $dst.'/'.$file, $files);
                } else {
                    copy($src.'/'.$file, $dst.'/'.$file);
                    if (\is_array($files)) {
                        $files[] = $dst.'/'.$file;
                    }
                }
            }
        }
        closedir($dir);
    }
1122627
public void copyToLocalFile(boolean delSrc, boolean validate,
      Path src, Path dst)
  throws IOException {
    FileUtil.copy(this, src, getLocal(getConf()), dst, delSrc,
        validate, getConf());
  }
868054
def move_file(self, src, dst):
        

        src = self.get_full_file_path(src); dst = self.get_full_file_path(dst)

        # record where file moved
        if os.path.isfile(src):
            # if destination file exists, copy it to tmp first
            if os.path.isfile(dst):
                tmp_path = self.new_tmp()
                self.do_action({
                    'do'   : ['copy', dst, tmp_path],
                    'undo' : ['move', tmp_path, dst]})

        self.do_action(
            {'do'   : ['move', src, dst],
             'undo' : ['move', dst, src]})
1167035
def copyfileobj(src, dst, length=None, exception=OSError, bufsize=None):
    
    if bufsize is None:
        bufsize = pipebuf.PIPE_BUF_BYTES

    if length == 0:
        return
    if length is None:
        shutil.copyfileobj(src, dst, bufsize)
        return

    blocks, remainder = divmod(length, bufsize)
    for b in range(blocks):
        buf = src.read(bufsize)
        if len(buf) < bufsize:
            raise exception("unexpected end of data")
        dst.write(buf)

    if remainder != 0:
        buf = src.read(remainder)
        if len(buf) < remainder:
            raise exception("unexpected end of data")
        dst.write(buf)
    return
1317717
public static void copyBuffer(WsByteBuffer src, WsByteBuffer dst) {
        copyBuffer(src, dst, src.remaining());
    }
570819
def copyfile(src, dst):
    """"""
    if _samefile(src, dst):
        raise Error("`%s` and `%s` are the same file" % (src, dst))

    for fn in [src, dst]:
        try:
            st = os.stat(fn)
        except OSError:
            # File most likely does not exist
            pass
        else:
            # XXX What about other special files? (sockets, devices...)
            if stat.S_ISFIFO(st.st_mode):
                raise SpecialFileError("`%s` is a named pipe" % fn)

    with open(src, 'rb') as fsrc:
        with open(dst, 'wb') as fdst:
            copyfileobj(fsrc, fdst)
46586
def cp(src, dst, overwrite=False):
    

    if not isinstance(src, list):
        src = [src]

    dst = os.path.expanduser(dst)
    dst_folder = os.path.isdir(dst)

    if len(src) > 1 and not dst_folder:
        raise OSError("Cannot copy multiple item to same file")

    for item in src:
        source = os.path.expanduser(item)
        destination = (dst if not dst_folder else
                       os.path.join(dst, os.path.basename(source)))
        if not overwrite and os.path.exists(destination):
            _logger.warning("Not replacing {0} with {1}, overwrite not enabled"
                            "".format(destination, source))
            continue

        shutil.copy(source, destination)
1244600
def copytree(src, dst):
    
    from os import path, waitpid
    from subprocess import Popen, PIPE

    #Append any trailing / that we need to get rsync to work correctly.
    source = path.join(src, "")
    desti = path.join(dst, "")
    if not path.isdir(desti):
        from os import mkdir
        mkdir(desti)
    
    prsync = Popen("rsync -t -u -r {} {}".format(source, desti), close_fds=True,
                    shell=True, executable="/bin/bash", stdout=PIPE, stderr=PIPE)
    waitpid(prsync.pid, 0)
    #Redirect the output and errors so that we don't pollute stdout.
    #output = prsync.stdout.readlines()
    error = prsync.stderr.readlines()
    prsync.stderr.close()
    prsync.stdout.close()

    if len(error) > 0:
        from fortpy.msg import warn
        warn("Error while copying {} using rsync.\n\n{}".format(source, '\n'.join(error)))
501343
def _copy_chunk(src, dst, length):
    ""
    BUFSIZE = 128 * 1024
    while length > 0:
        l = min(BUFSIZE, length)
        buf = src.read(l)
        assert len(buf) == l
        dst.write(buf)
        length -= l
239246
def copytree(src, dst, symlinks=False, ignore=None):
    """"""

    # TODO(crow): OSError: [Errno 17] File exists
    if not osp.exists(dst):
        os.makedirs(dst)
    for item in os.listdir(src):
        s = osp.join(src, item)
        d = osp.join(dst, item)
        if osp.isdir(s):
            shutil.copytree(s, d, symlinks, ignore)
        else:
            shutil.copy2(s, d)
476690
def move(self, src, dst):
        
        url = '/'.join([src.drive,
                        'api/move',
                        str(src.relative_to(src.drive)).rstrip('/')])

        params = {'to': str(dst.relative_to(dst.drive)).rstrip('/')}

        text, code = self.rest_post(url,
                                    params=params,
                                    auth=src.auth,
                                    verify=src.verify,
                                    cert=src.cert)

        if code not in [200, 201]:
            raise RuntimeError("%s" % text)
1069293
def _copy_content(self, origin, dstPath):
        

        if hasattr(origin, 'read'):
            copy_content(origin, dstPath, self.BLOCK_SIZE, self._conf['fmode'])
        elif os.path.isfile(origin):
            with open(origin, 'rb') as f:
                copy_content(f, dstPath, self.BLOCK_SIZE, self._conf['fmode'])
        else:
            raise ValueError("Could not copy content, `origin` should be a path or a readable object")
748687
def copy_files(src_dir, dst_dir, filespec='*', recursive=False):
    
    import os
    from .modules import copyfiles

    if src_dir == dst_dir:
        raise RuntimeError('copy_files() src and dst directories must be different.')

    if not os.path.isdir(src_dir):
        raise RuntimeError('copy_files() src directory "{}" does not exist.'.format(src_dir))

    return {
        'dependencies_fn': copyfiles.list_files,
        'compiler_fn': copyfiles.copy_files,
        'input': src_dir,
        'output': dst_dir,
        'kwargs': {
            'filespec': filespec,
            'recursive': recursive,
        },
    }