Copy file/dir resource to destination.

    Parameters
    ----------
    package_or_requirement : str
    resource_name : str
    destination : ~pathlib.Path
        Path to copy to, it must not exist.
333835
def resource_copy(package_or_requirement, resource_name, destination):
    '''
    
    '''
    args = package_or_requirement, resource_name
    if resource_isdir(*args):
        destination.mkdir()
        for name in resource_listdir(*args):
            resource_copy(
                package_or_requirement,
                str(Path(resource_name) / name),
                destination / name
            )
    else:
        with destination.open('wb') as f:
            with resource_stream(*args) as source:
                shutil.copyfileobj(source, f)
647541
def copy_helper(app_or_project, name, directory, dist, template_dir, noadmin):
    

    import shutil
    if not re.search(r'^[_a-zA-Z]\w*$', name): # If it's not a valid directory name.
        # Provide a smart error message, depending on the error.
        if not re.search(r'^[_a-zA-Z]', name):
            message = 'make sure the name begins with a letter or underscore'
        else:
            message = 'use only numbers, letters and underscores'
        raise CommandError("%r is not a valid project name. Please %s." % (name, message))
    top_dir = os.path.join(directory, dist)
    try:
        os.mkdir(top_dir)
    except OSError, e:
        raise CommandError(e)
        
    for d, subdirs, files in os.walk(template_dir):
        relative_dir = d[len(template_dir)+1:].replace('project_name', name)
        if relative_dir:
            os.mkdir(os.path.join(top_dir, relative_dir))
        for subdir in subdirs[:]:
            if subdir.startswith('.'):
                subdirs.remove(subdir)
        for f in files:
            if not f.endswith('.py'):
                # Ignore .pyc, .pyo, .py.class etc, as they cause various
                # breakages.
                continue
            path_old = os.path.join(d, f)
            path_new = os.path.join(top_dir, relative_dir, f.replace('project_name', name))
            fp_old = open(path_old, 'r')
            fp_new = open(path_new, 'w')
            if noadmin:
                fp_new.write(fp_old.read().replace('{{ project_name }}', name))
            else:
                fp_new.write(fp_old.read().replace('{{ project_name }}', name).replace('## ',''))
            fp_old.close()
            fp_new.close()
            try:
                shutil.copymode(path_old, path_new)
                _make_writeable(path_new)
            except OSError:
                sys.stderr.write(style.NOTICE("Notice: Couldn't set permission bits on %s. You're probably using an uncommon filesystem setup. No problem.\n" % path_new))
474500
def copy_file_if_needed!(filename: nil, dry_run: false)
      needs_update = file_needs_update?(filename: filename)
      UI.verbose("file #{filename} needs an update") if needs_update

      # Ok, we know if this file needs an update, can return now if it's a dry run
      return needs_update if dry_run

      unless needs_update
        # no work needed, just return
        return false
      end

      source = File.join(self.source_swift_code_file_folder_path, "/#{filename}")
      target = File.join(self.target_swift_code_file_folder_path, "/#{filename}")

      FileUtils.cp(source, target)
      UI.verbose("Copied #{source} to #{target}")
      return true
    end
525736
function copyFileIntoDirectory(srcPath, destPath) {
        return ensureDestinationDirectory(destPath).then(function () {
            return new Promise(function (resolve, reject) {
                fs.readFile(srcPath, 'utf8', function (err, contents) {
                    if (!err) {
                        resolve();
                    } else {
                        reject(err);
                    }
                    fs.outputFile(destPath + '/' + path.basename(srcPath), contents, function (err) {
                        if (!err) {
                            resolve();
                        } else {
                            reject(err);
                        }
                    });
                });
            });
        });
    }
718885
def walk_resources(package_or_requirement, resource_name, recurse=True, base=''):
    
    base = base.rstrip('/') + '/'
    resource_base = (resource_name.rstrip('/') + '/' + base.strip('/')).rstrip('/')

    # Create default configuration files
    for filename in pymagic.resource_listdir(package_or_requirement, resource_base):
        # Skip hidden and other trashy names
        if filename.startswith('.') or any(filename.endswith(i) for i in (".pyc", ".pyo", "~")):
            continue

        # Handle subdirectories
        if pymagic.resource_isdir(package_or_requirement, resource_base + '/' + filename):
            if recurse:
                for i in walk_resources(package_or_requirement, resource_name, recurse, base=base + filename):
                    yield i
        else:
            yield base + filename
1320502
def generate(organization, package, destination):
    
    gen = ResourceGenerator(organization, package)

    tmp = tempfile.NamedTemporaryFile(mode='w+t', delete=False)
    try:
        tmp.write(gen.conf())
    finally:
        tmp.close()

    shutil.copy(tmp.name, os.path.join(destination, 'conf.py'))

    tmp = tempfile.NamedTemporaryFile(mode='w+t', delete=False)
    try:
        tmp.write(gen.makefile())
    finally:
        tmp.close()

    shutil.copy(tmp.name, os.path.join(destination, 'Makefile'))
1024158
def copy_file(self, src_path, file_name, key=None):
        
        path = os.path.join(self._directories[key], file_name)
        shutil.copyfile(src_path, path)
962052
public void copyResourceToDir(String path, String filename, String dir) {
		String fullpath = path + ProcessorConstants.SEPARATORCHAR + filename;
		messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " javascript copy js : " + fullpath + " to : "+dir);
		try (Writer writer = getFileObjectWriter(dir, "org.ocelotds."+filename)) {
			bodyWriter.write(writer, OcelotProcessor.class.getResourceAsStream(fullpath));
		} catch (IOException ex) {
			messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " FAILED TO CREATE : " + filename);
		}
	}
904561
def copy_file(self, path, prefixed_path, source_storage):
        
        args = (path, prefixed_path, source_storage)
        if settings.threads:
            self.tasks.append(args)
        else:
            self.do_copy_file(args)
377389
public static Optional<Path> moveDir(Path sourceDirPath,
            Path destinationDirPath, CopyOption... options) {
        return operateDir(sourceDirPath, destinationDirPath, sourceDirPath,
                path -> move(path, destinationDirPath, options));
    }
657782
def copy_resource(self, resource, targetdir):
        """"""
        final_path = resource.final_path()
        if final_path[0] == '/' or (':' in final_path) or ('?' in final_path):
            # Absolute path or URI: Do nothing
            return

        source_path = self.get_source_path(resource)

        if resource.resource_type == DIRECTORY_RESOURCE:
            for file_path in glob.iglob(os.path.join(source_path, '**'), recursive=True):
                if os.path.isdir(file_path):
                    continue
                rest_target_path = file_path[len(source_path)+1:]
                target_path = os.path.join(targetdir, final_path, rest_target_path)
                # Don't yield the result, we don't monitor these.
                self._copy_file(file_path, target_path)
        else:
            target_path = os.path.join(targetdir, final_path)
            yield self._copy_file(source_path, target_path)
1368886
public void copyLibraryFromPackage(String libraryName) throws IOException {
        Path ardDir = getArduinoDirectory().orElseThrow(IOException::new);
        Path source = Paths.get(embeddedDirectory).resolve(libraryName);

        Path dest = ardDir.resolve("libraries/" + libraryName);
        if(!Files.exists(dest)) {
            Files.createDirectory(dest);
        }

        Path gitRepoDir = dest.resolve(".git");
        if(Files.exists(gitRepoDir)) {
            throw new IOException("Git repository inside " + libraryName+ "! Not proceeding to update path : " + dest);
        }

        copyLibraryRecursive(source, dest);
    }
1129365
def copy_or_replace(src, dst):
    '''
    '''
    try:
        shutil.copy(src, dst)
    except (OSError, IOError), e:
        # It's possible that the file existed, but was owned by someone
        # else - in that situation, shutil.copy might then fail when it
        # tries to copy perms.
        # However, it's possible that we have write perms to the dir -
        # in which case, we can just delete and replace
        import errno

        if e.errno == errno.EPERM:
            import tempfile
            # try copying into a temporary location beside the old
            # file - if we have perms to do that, we should have perms
            # to then delete the old file, and move the new one into
            # place
            if os.path.isdir(dst):
                dst = os.path.join(dst, os.path.basename(src))

            dst_dir, dst_name = os.path.split(dst)
            dst_temp = tempfile.mktemp(prefix=dst_name + '.', dir=dst_dir)
            shutil.copy(src, dst_temp)
            if not os.path.isfile(dst_temp):
                raise RuntimeError(
                    "shutil.copy completed successfully, but path"
                    " '%s' still did not exist" % dst_temp)
            os.remove(dst)
            shutil.move(dst_temp, dst)
33004
def copy(from_path, to_path)
      resp = request('/files/copy', from_path: from_path, to_path: to_path)
      parse_tagged_response(resp)
    end
1365035
def link_or_copy(src, dst, verbosity=0):
    
    if verbosity > 0:
        log_info("Copying %s -> %s" % (src, dst))
    try:
        os.link(src, dst)
    except (AttributeError, OSError):
        try:
            shutil.copy(src, dst)
        except OSError as msg:
            raise PatoolError(msg)
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)
99283
def zip(name, options = {})
      url = options.fetch(:url)
      remote_source = RemoteSources::Zip.new(url)
      packages << Package.new(name, remote_source, options)
    end