Copies the file from source to target

        Args:
            startimage (str): name of the image to stage these files into
            newimage (str): name of the created image
10579
def stage(self, startimage, newimage):
        
        client = utils.get_client()
        cprint('  Copying file from "%s:/%s" \n                 to "%s://%s/"'
               % (self.sourceimage, self.sourcepath, startimage, self.destpath),
               'blue')

        # copy build artifacts from the container if necessary
        cachedir = self._setcache(client)
        cacherelpath = os.path.relpath(cachedir, TMPDIR)

        # if cached file doesn't exist (presumably purged by OS), trigger it to be recreated
        if os.path.exists(cachedir) and not os.path.exists(os.path.join(cachedir, 'content.tar')):
            shutil.rmtree(cachedir)

        if not os.path.exists(cachedir):
            print(' * Creating cache at %s' % cacherelpath)
            container = client.containers.create(self.sourceimage)
            try:
                tarfile_stream, tarfile_stats = container.get_archive(self.sourcepath)
            except docker.errors.NotFound:
                raise errors.MissingFileError(
                        'Cannot copy file "%s" from image "%s" - it does not exist!' %
                        (self.sourcepath, self.sourceimage))

            # write files to disk (would be nice to stream them, haven't gotten it to work)
            tempdir = tempfile.mkdtemp(dir=BUILD_TEMPDIR)
            with open(os.path.join(tempdir, 'content.tar'), 'wb') as localfile:
                for chunk in tarfile_stream:
                    localfile.write(chunk)
            os.mkdir(cachedir)
            os.rename(tempdir, cachedir)
        else:
            print('  Using cached files from %s' % cacherelpath)

        # write Dockerfile for the new image and then build it
        dockerfile = 'FROM %s\nADD content.tar %s' % (startimage, self.destpath)
        with open(os.path.join(cachedir, 'Dockerfile'), 'w') as df:
            df.write(dockerfile)

        buildargs = dict(path=cachedir,
                         tag=newimage,
                         decode=True)
        utils.set_build_cachefrom(self.cache_from, buildargs, client)

        # Build and show logs
        stream = client.api.build(**buildargs)
        try:
            utils.stream_docker_logs(stream, newimage)
        except ValueError as e:
            raise errors.BuildError(dockerfile, e.args[0], build_args=buildargs)
815075
def copy_image_on_background(image, color=WHITE):
    
    background = Image.new("RGB", image.size, color)
    background.paste(image, mask=image.split()[3])
    return background
739423
def copy_contents(self, fileinstance, progress_callback=None,
                      chunk_size=None, **kwargs):
        """"""
        if not fileinstance.readable:
            raise ValueError('Source file instance is not readable.')
        if not self.size == 0:
            raise ValueError('File instance has data.')

        self.set_uri(
            *self.storage(**kwargs).copy(
                fileinstance.storage(**kwargs),
                chunk_size=chunk_size,
                progress_callback=progress_callback))
666913
def copy_images(from, to)
      return unless File.exist?(from)
      Dir.mkdir(to)
      ReVIEW::MakerHelper.copy_images_to_dir(from, to)
      Dir.chdir(to) do
        images = Dir.glob('**/*').find_all { |f| File.file?(f) and f =~ /\.(jpg|jpeg|png|pdf|ai|eps|tif)\z/i }
        break if images.empty?
        if @config['pdfmaker']['bbox']
          system_with_info('extractbb', '-B', @config['pdfmaker']['bbox'], *images)
          system_or_raise('ebb', '-B', @config['pdfmaker']['bbox'], *images) unless system('extractbb', '-B', @config['pdfmaker']['bbox'], '-m', *images)
        else
          system_with_info('extractbb', *images)
          system_or_raise('ebb', *images) unless system('extractbb', '-m', *images)
        end
      end
    end
657615
def on_background_source(self, *args):
        
        if self.background_source:
            self.background_image = Image(source=self.background_source)
927066
def image_to_file(self, path):
        
        _LOGGER.debug("Writing image from %s to %s", self.name, path)
        response = self._cached_image
        if response.status_code == 200:
            with open(path, 'wb') as imgfile:
                copyfileobj(response.raw, imgfile)
        else:
            _LOGGER.error("Cannot write image to file, response %s",
                          response.status_code,
                          exc_info=True)
564236
def insert(exif, image, new_file=None):
    
    if exif[0:6] != b"\x45\x78\x69\x66\x00\x00":
        raise ValueError("Given data is not exif data")

    output_file = False
    # Prevents "UnicodeWarning: Unicode equal comparison failed" warnings on Python 2
    maybe_image = sys.version_info >= (3,0,0) or isinstance(image, str)

    if maybe_image and image[0:2] == b"\xff\xd8":
        image_data = image
        file_type = "jpeg"
    elif maybe_image and image[0:4] == b"RIFF" and image[8:12] == b"WEBP":
        image_data = image
        file_type = "webp"
    else:
        with open(image, 'rb') as f:
            image_data = f.read()
        if image_data[0:2] == b"\xff\xd8":
            file_type = "jpeg"
        elif image_data[0:4] == b"RIFF" and image_data[8:12] == b"WEBP":
            file_type = "webp"
        else:
            raise InvalidImageDataError
        output_file = True

    if file_type == "jpeg":
        exif = b"\xff\xe1" + struct.pack(">H", len(exif) + 2) + exif
        segments = split_into_segments(image_data)
        new_data = merge_segments(segments, exif)
    elif file_type == "webp":
        exif = exif[6:]
        new_data = _webp.insert(image_data, exif)

    if isinstance(new_file, io.BytesIO):
        new_file.write(new_data)
        new_file.seek(0)
    elif new_file:
        with open(new_file, "wb+") as f:
            f.write(new_data)
    elif output_file:
        with open(image, "wb+") as f:
            f.write(new_data)
    else:
        raise ValueError("Give a 3rd argument to 'insert' to output file")
1088298
def create(self, original, size, crop, options=None):
        
        if options is None:
            options = self.evaluate_options()
        image = self.engine_load_image(original)
        image = self.scale(image, size, crop, options)
        crop = self.parse_crop(crop, self.get_image_size(image), size)
        image = self.crop(image, size, crop, options)
        image = self.colormode(image, options)
        return image
282861
def put_image(self, name, val):
        
        assert isinstance(val, np.ndarray)
        arr = image_to_nhwc(val)
        self._dispatch(lambda m: m.process_image(name, arr))
        s = create_image_summary(name, arr)
        self._dispatch(lambda m: m.process_summary(s))
729650
def maybe_copy_file_to_directory(source_filepath, target_directory):
  
  if not tf.gfile.Exists(target_directory):
    tf.logging.info("Creating directory %s" % target_directory)
    os.mkdir(target_directory)
  target_filepath = os.path.join(target_directory,
                                 os.path.basename(source_filepath))
  if not tf.gfile.Exists(target_filepath):
    tf.logging.info("Copying %s to %s" % (source_filepath, target_filepath))
    tf.gfile.Copy(source_filepath, target_filepath)
    statinfo = os.stat(target_filepath)
    tf.logging.info("Successfully copied %s, %s bytes." % (target_filepath,
                                                           statinfo.st_size))
  else:
    tf.logging.info("Not copying, file already found: %s" % target_filepath)
  return target_filepath
569887
def copy_assets(self, path='assets'):
		
		path = os.path.join(self.root_path, path)
		for root, _, files in os.walk(path):
			for file in files:
				fullpath = os.path.join(root, file)
				relpath = os.path.relpath(fullpath, path)
				copy_to = os.path.join(self._get_dist_path(relpath, directory='assets'))
				LOG.debug('copying %r to %r', fullpath, copy_to)
				shutil.copyfile(fullpath, copy_to)
1372570
def from_image_to_file(img_path, file_path):
    
    img = Image.open(img_path)
    data = numpy.array(img)
    data = numpy.reshape(data, len(img.getdata()) * 3)
    to_remove = data[len(data) - 1]
    data = numpy.delete(data, xrange(len(data) - to_remove, len(data)))
    data.tofile(file_path)
371970
def rebase(self, qemu_img, base_image):
        

        if not os.path.exists(base_image):
            raise FileNotFoundError(base_image)
        command = [qemu_img, "rebase", "-u", "-b", base_image, self._path]
        process = yield from asyncio.create_subprocess_exec(*command)
        retcode = yield from process.wait()
        if retcode != 0:
            raise Qcow2Error("Could not rebase the image")
        self._reload()
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)
751335
def clone(self) -> 'ImageBBox':
        ""
        flow = FlowField(self.size, self.flow.flow.clone())
        return self.__class__(flow, scale=False, y_first=False, labels=self.labels, pad_idx=self.pad_idx)
500356
def copy(self, src, chunk_size=None, progress_callback=None):
        
        fp = src.open(mode='rb')
        try:
            return self.save(
                fp, chunk_size=chunk_size, progress_callback=progress_callback)
        finally:
            fp.close()
1335959
def copymode(self, target):
        
        shutil.copymode(self.path, self._to_backend(target))