Save the plot as a PDF file.

        Save and render the plot using LaTeX to create a PDF file.

        :param dest_path: path of the file.
540196
def save_as_pdf(self, dest_path):
        
        dest_path = self._add_extension('pdf', dest_path)
        build_dir = tempfile.mkdtemp()
        build_path = os.path.join(build_dir, 'document.tex')
        self.save_assets(build_path)
        with open(build_path, 'w') as f:
            f.write(self.render())
        pdf_path = self._build_document(build_path)
        shutil.copyfile(pdf_path, dest_path)
        shutil.rmtree(build_dir)
639773
def save_file(f, full_path):
    
    make_dirs_for_file_path(full_path, mode=dju_settings.DJU_IMG_CHMOD_DIR)
    with open(full_path, 'wb') as t:
        f.seek(0)
        while True:
            buf = f.read(dju_settings.DJU_IMG_RW_FILE_BUFFER_SIZE)
            if not buf:
                break
            t.write(buf)
    os.chmod(full_path, dju_settings.DJU_IMG_CHMOD_FILE)
860858
def save_hdf5(X, y, path):
    

    with h5py.File(path, 'w') as f:
        is_sparse = 1 if sparse.issparse(X) else 0
        f['issparse'] = is_sparse
        f['target'] = y

        if is_sparse:
            if not sparse.isspmatrix_csr(X):
                X = X.tocsr()

            f['shape'] = np.array(X.shape)
            f['data'] = X.data
            f['indices'] = X.indices
            f['indptr'] = X.indptr
        else:
            f['data'] = X
914241
def path_to_text(self, path):
        '''
        

        '''
        rsrcmgr = PDFResourceManager()
        retstr = StringIO()
        codec = 'utf-8'
        laparams = LAParams()
        device = TextConverter(rsrcmgr, retstr, codec=codec, laparams=laparams)
        fp = open(path, 'rb')
        interpreter = PDFPageInterpreter(rsrcmgr, device)
        password = ""
        maxpages = 0
        caching = True
        pagenos = set()

        pages_data = PDFPage.get_pages(
            fp,
            pagenos,
            maxpages=maxpages,
            password=password,
            caching=caching,
            check_extractable=True
        )

        for page in pages_data:
            interpreter.process_page(page)

        text = retstr.getvalue()
        text = text.replace("\n", "")

        fp.close()
        device.close()
        retstr.close()
        return text
262990
def save(self, path):
        
        with open(path, 'w') as f:
            f.write(self.contents())
227560
def img2pdf(path, pdf_name=None):
    
    print("merge images in %s ..." % path)
    if not pdf_name:
        pdf_name = os.path.join(path, '%s.pdf' % os.path.split(path)[1])
    file_list = os.listdir(path)

    # filter pic in path
    pic_names = []
    img_suffix = ['.png', '.jpg', '.jpeg']
    for x in file_list:
        _, suffix = os.path.splitext(x)
        if suffix.lower() in img_suffix:
            pic_names.append(os.path.join(path, x))
    pic_names.sort()

    if len(pic_names) == 0:
        print("There is no images in %s" % path)
        return

    im_list = []
    im1 = Image.open(pic_names[0])
    pic_names.pop(0)
    for i in pic_names:
        img = Image.open(i)
        if img.mode == "RGBA":
            img = img.convert('RGB')
            im_list.append(img)
        else:
            im_list.append(img)
    im1.save(pdf_name, "PDF", resolution=100.0, save_all=True,
             append_images=im_list)
    print("images saved to：", pdf_name)
208363
def save_to_path(self, file_path, chunk_size=DOWNLOAD_FILE_CHUNK_SIZE):
        
        response = self._get_download_response()
        with open(file_path, 'wb') as f:
            for chunk in response.iter_content(chunk_size=chunk_size):
                if chunk:  # filter out keep-alive new chunks
                    f.write(chunk)
235163
def to_csv(self, dest:str)->None:
        ""
        self.to_df().to_csv(self.path/dest, index=False)
44977
public function saveFromView($view, $path)
    {
        $this->generateFilePaths();
        $this->generatePdf($view);

        rename($this->pdfPath, $path);
    }
1107887
def save_plot(self, filename, img_format="eps", **kwargs):
        
        plt = self.get_plot(**kwargs)
        plt.savefig(filename, format=img_format)
1147342
def paths_to_pdfs
      paths = []
      
      Zip::ZipFile.open(path) do |zipfile|
        zipfile.select { |file| zipfile.get_entry(file).file? }.each do |file|
          paths << file.name if file.name.end_with? ".pdf"
        end
      end
      
      paths
    end
1175123
def save_obj(self, path, update_normals=True):
        
        if update_normals:
            self.update_normals()

        # Create triangle_list
        vectors_key_list = []
        vectors_list = []
        normals_key_list = []
        normals_list = []
        triangle_list = []
        for i, vector in enumerate(self.vectors):
            one_triangle = []
            for j in range(3):
                v_key = ",".join(map(str, self.vectors[i][j][:3]))
                if v_key in vectors_key_list:
                    v_index = vectors_key_list.index(v_key)
                else:
                    v_index = len(vectors_key_list)
                    vectors_key_list.append(v_key)
                    vectors_list.append(self.vectors[i][j][:3])
                one_triangle.append(v_index + 1)

            n_key = ",".join(map(str, self.normals[i][:3]))
            if n_key in normals_key_list:
                n_index = normals_key_list.index(n_key)
            else:
                n_index = len(normals_key_list)
                normals_key_list.append(n_key)
                normals_list.append(self.normals[i][:3])

            # print(normals_list)
            triangle_list.append((one_triangle, n_index + 1))

        with open(path, "wb") as fh:
            print("# {} {}".format(__title__, __version__), file=fh)
            print("# {}".format(datetime.datetime.now()), file=fh)
            print("# {}".format(__url__), file=fh)
            print("", file=fh)
            for v in vectors_list:
                print("v {} {} {}".format(v[0], v[1], v[2]), file=fh)
            for vn in normals_list:
                print("vn {} {} {}".format(vn[0], vn[1], vn[2]), file=fh)
            for t in triangle_list:
                faces = t[0]
                normal = t[1]

                print("f {}//{} {}//{} {}//{}".format(
                    faces[0], normal,
                    faces[1], normal,
                    faces[2], normal,
                ), file=fh)
1362743
def latex_output_graph(self, node):
    
    graph = node['graph']
    parts = node['parts']

    graph_hash = get_graph_hash(node)
    name = "inheritance%s" % graph_hash
    dest_path = os.path.abspath(os.path.join(setup.app.builder.outdir, '_images'))
    if not os.path.exists(dest_path):
        os.makedirs(dest_path)
    pdf_path = os.path.abspath(os.path.join(dest_path, name + ".pdf"))

    graph.run_dot(['-Tpdf', '-o%s' % pdf_path],
                  name, parts, graph_options={'size': '"6.0,6.0"'})
    return '\n\\includegraphics{%s}\n\n' % pdf_path
824743
def generate_tex(self, filepath):
        

        with open(filepath + '.tex', 'w', encoding='utf-8') as newf:
            self.dump(newf)
1360095
def _create_plot(tumor, in_glob, out_ext, page=1):
    
    out_dir = utils.safe_makedir("images")
    out_name = os.path.join(out_dir, "%s-%s" % (tumor, out_ext))
    in_file = glob.glob(in_glob)[0]
    cmd = ["pdftoppm", in_file, out_name, "-png", "-f", page, "-singlefile"]
    if not os.path.exists(out_name + ".png"):
        subprocess.check_call([str(x) for x in cmd])
    return out_name + ".png"
749749
def write(dest)
      path = destination(dest)
      FileUtils.mkdir_p(File.dirname(path))
      File.write(path, output, :mode => "wb")
      Bunto::Hooks.trigger hook_owner, :post_write, self
    end
504523
def image_export(cls, source_path, dest_url, **kwargs):
        
        dest_path = urlparse.urlparse(dest_url).path
        if kwargs['remote_host']:
            target_path = ':'.join([kwargs['remote_host'], dest_path])
            command = ' '.join(['/usr/bin/scp',
                                "-P", CONF.zvm.remotehost_sshd_port,
                                "-o StrictHostKeyChecking=no",
                                '-r ', source_path, target_path])
            (rc, output) = zvmutils.execute(command)
            if rc:
                msg = ("Error happened when copying image file to remote "
                       "host with reason: %s" % output)
                LOG.error(msg)
                raise exception.SDKImageOperationError(rs=21, msg=output)
        else:
            # Copy to local file system
            LOG.debug("Remote_host not specified, will copy to local server")
            try:
                shutil.copyfile(source_path, dest_path)
            except Exception as err:
                msg = ("Export image from %(src)s to local file system"
                       " %(dest)s failed: %(err)s" %
                       {'src': source_path,
                        'dest': dest_path,
                        'err': six.text_type(err)})
                LOG.error(msg)
                raise exception.SDKImageOperationError(rs=22,
                                                       err=six.text_type(err))