Copy a file or folder to the repository.

        Will mount if needed.

        Args:
            filename: Path to copy.
            destination: Remote path to copy file to.
5679
def _copy(self, filename, destination):
        
        super(MountedRepository, self)._copy(filename, destination)
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)
535969
def copy_file(src, dst, ignore=None):
   
   # Sanity checkpoint
   src = re.sub('[^\w/\-\.\*]', '', src)
   dst = re.sub('[^\w/\-\.\*]', '', dst)
   if len(re.sub('[\W]', '', src)) < 5 or len(re.sub('[\W]', '', dst)) < 5:
      debug.log("Error: Copying file failed. Provided paths are invalid! src='%s' dst='%s'"%(src, dst))
   else:
      # Check destination
      check = False
      if dst[-1] == '/':
         if os.path.exists(dst):
            check = True # Valid Dir
         else:
            debug.log("Error: Copying file failed. Destination directory does not exist (%s)"%(dst)) #DEBUG
      elif os.path.exists(dst):
         if os.path.isdir(dst):
            check = True # Valid Dir
            dst += '/' # Add missing slash
         else:
            debug.log("Error: Copying file failed. %s exists!"%dst)
      elif os.path.exists(os.path.dirname(dst)):
         check = True # Valid file path
      else:
         debug.log("Error: Copying file failed. %s is an invalid distination!"%dst)
      if check:
         # Check source
         files = glob.glob(src)
         if ignore is not None: files = [fil for fil in files if not ignore in fil]
         if len(files) != 0:
            debug.log("Copying File(s)...", "Copy from %s"%src, "to %s"%dst) #DEBUG
            for file_ in files:
               # Check file exists
               if os.path.isfile(file_):
                  debug.log("Copying file: %s"%file_) #DEBUG
                  shutil.copy(file_, dst)
               else:
                  debug.log("Error: Copying file failed. %s is not a regular file!"%file_) #DEBUG
         else: debug.log("Error: Copying file failed. No files were found! (%s)"%src)
890927
def copy(self, path_patterns, symbolic_link=False, root=None,
             conflicts='fail'):
        '''  '''
        new_filename = build_path(self.entities, path_patterns)
        if not new_filename:
            return None

        if new_filename[-1] == os.sep:
            new_filename += self.filename

        if isabs(self.path) or root is None:
            path = self.path
        else:
            path = join(root, self.path)

        if not exists(path):
            raise ValueError("Target filename to copy/symlink (%s) doesn't "
                             "exist." % path)

        if symbolic_link:
            contents = None
            link_to = path
        else:
            with open(path, 'r') as f:
                contents = f.read()
            link_to = None

        write_contents_to_file(new_filename, contents=contents,
                               link_to=link_to, content_mode='text', root=root,
                               conflicts=conflicts)
305327
def copy_remote_file(web_file, destination):
    
    size = 0
    dir_name = os.path.dirname(destination)
    if not os.path.exists(dir_name):
        os.makedirs(dir_name)

    with open(destination, 'wb') as file_:
        chunk_size = 8 * 1024
        for chunk in web_file.iter_content(chunk_size=chunk_size):
            if chunk:
                file_.write(chunk)
                size += len(chunk)
    return size
1053654
def put(self, filename, encoding=None):
        
        from . import LocalFile

        if os.path.isdir(filename) and self.source is None:
            raise ValueError("Cannot write this object to "
                             "directory %s without an explicit filename." % filename)

        target = get_target_path(filename, self.source)

        if (encoding is not None) and (encoding != self.encoded_with):
            raise ValueError('%s is already encoded as "%s"' % self, self.encoded_with)

        with self.open('rb') as infile, open(target, 'wb') as outfile:
            for line in infile:
                outfile.write(line)
        return LocalFile(target)
906748
public static void copyFiles(String[] files, String[] destinationFiles) throws IOException {
        copyFiles(getFiles(files), getFiles(destinationFiles));
    }
1303711
def copy_files(filename, dstfilename):
        # type: (AnyStr, AnyStr) -> None
        """"""
        FileClass.remove_files(dstfilename)
        dst_prefix = os.path.splitext(dstfilename)[0]
        pattern = os.path.splitext(filename)[0] + '.*'
        for f in glob.iglob(pattern):
            ext = os.path.splitext(f)[1]
            dst = dst_prefix + ext
            copy(f, dst)
131386
def move(self, filename, target):
        '''
        
        '''
        self.copy(filename, target)
        self.delete(filename)
1005626
def recursive_copy(source, destination):
    
    if os.path.isdir(source):
        copy_tree(source, destination)
199376
def copy_file_to_remote(self, local_path, remote_path):
        
        sftp_client = self.transport.open_sftp_client()
        LOG.debug('Copy the local file to remote. '
                  'Source=%(src)s. Target=%(target)s.' %
                  {'src': local_path, 'target': remote_path})
        try:
            sftp_client.put(local_path, remote_path)
        except Exception as ex:
            LOG.error('Failed to copy the local file to remote. '
                      'Reason: %s.' % six.text_type(ex))
            raise SFtpExecutionError(err=ex)
236054
def copy_pkg(self, filename, _):
        
        basename = os.path.basename(filename)
        self._copy(filename, os.path.join(self.connection["mount_point"],
                                          "Packages", basename))
959702
public static void copyFile(String fileName, String newFileName, boolean overwriteExisting) throws IOException {
		copyFile(new File(fileName), newFileName, overwriteExisting);
	}
268574
def copy_file_to_agent(
        host,
        file_path,
        remote_path='.',
        username=None,
        key_path=None
):
    

    return copy_file(host, file_path, remote_path, username, key_path)
399425
public static void copyRecursively(Path source, Path destination) throws IOException {
        if (Files.isDirectory(source))
        {
            Files.createDirectories(destination);
            final Set<Path> sources = listFiles(source);

            for (Path srcFile : sources)
            {
                Path destFile = destination.resolve(srcFile.getFileName());
                copyRecursively(srcFile, destFile);
            }
        }
        else
        {
            Files.copy(source, destination, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
        }
    }
726174
def copy(source, destination):
    

    try:
        if os.path.isfile(source):
            LOGGER.debug("> Copying '{0}' file to '{1}'.".format(source, destination))
            shutil.copyfile(source, destination)
        else:
            LOGGER.debug("> Copying '{0}' directory to '{1}'.".format(source, destination))
            shutil.copytree(source, destination)
        return True
    except Exception as error:
        raise foundations.exceptions.PathCopyError(
            "!> {0} | Cannot copy '{1}' path: '{2}'".format(__name__, source, error))
1155802
def copyfile(self, target):
        
        shutil.copyfile(self.path, self._to_backend(target))