当前位置: 首页>>代码示例>>Python>>正文


Python pycode.get_temp_folder函数代码示例

本文整理汇总了Python中pyquickhelper.pycode.get_temp_folder函数的典型用法代码示例。如果您正苦于以下问题:Python get_temp_folder函数的具体用法?Python get_temp_folder怎么用?Python get_temp_folder使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_temp_folder函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_auc_file

    def test_auc_file(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        ans = [1, 1, 1, 1, 1, 0, 0, 0, 0]
        score = [i * 0.8 + 0.1 for i in ans]
        score[0] = 0.4
        score[-1] = 0.6
        fLOG(score)
        t1 = get_temp_folder(__file__, "temp_answers")
        t2 = get_temp_folder(__file__, "temp_scores")
        f1 = "answer.txt"
        f2 = "answer.txt"
        fu1 = os.path.join(t1, f1)
        fu2 = os.path.join(t2, f2)
        out = os.path.join(t2, "scores.txt")
        with open(fu1, "w") as f:
            f.write("\n".join(str(_) for _ in ans))
        with open(fu2, "w") as f:
            f.write("\n".join(str(_) for _ in score))
        private_codalab_wrapper_binary_classification(
            AUC, "AUC", t1, t2, output=out)
        assert os.path.exists(out)
        with open(out, "r") as f:
            code = f.read()
        fLOG("**", code)

        self.assertEqual(code, "AUC:0.95")
开发者ID:sdpython,项目名称:ensae_projects,代码行数:30,代码来源:test_competitions.py

示例2: test_encrypt_decrypt

    def test_encrypt_decrypt(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        password = "unittest" * 2

        temp = get_temp_folder(__file__, "temp_encrypt")
        temp2 = get_temp_folder(__file__, "temp_encrypt2")
        tempmm = get_temp_folder(__file__, "temp_encrypt_status")
        cstatus = os.path.join(tempmm, "crypt_status.txt")
        cmap = os.path.join(tempmm, "crypt_map.txt")
        srcf = os.path.abspath(os.path.join(temp, ".."))
        sys.argv = ["", srcf, temp, password,
                    "--status", cstatus,
                    "--map", cmap]
        encrypt(fLOG=fLOG)
        this = __file__

        sys.argv = ["", temp, temp2, password]
        decrypt(fLOG=fLOG)

        with open(__file__, "rb") as f:
            c1 = f.read()
        with open(os.path.join(temp2, os.path.split(this)[-1]), "rb") as f:
            c2 = f.read()

        self.assertEqual(c1, c2)
        fLOG("end")
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:30,代码来源:test_encryption_cli.py

示例3: test_install_revealjs

    def test_install_revealjs(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        temp = get_temp_folder(__file__, "temp_install_revealjs")
        dest = get_temp_folder(__file__, "temp_install_revealjs_dest")
        fs = download_revealjs(temp, dest, fLOG=fLOG)
        fLOG(fs)
        assert len(fs) > 0
        for a in fs:
            assert os.path.exists(a)
开发者ID:sdpython,项目名称:pymyinstall,代码行数:13,代码来源:test_revealjs.py

示例4: test_rst_only

    def test_rst_only(self):
        from docutils import nodes as skip_

        content = """
                    test a directive
                    ================

                    .. only:: html

                        only for html

                    .. only:: rst

                        only for rst

                    """.replace("                    ", "")
        if sys.version_info[0] >= 3:
            content = content.replace('u"', '"')

        tives = [("cmdref", CmdRef, cmdref_node,
                  visit_cmdref_node, depart_cmdref_node)]

        text = rst2html(content,  # fLOG=fLOG,
                        writer="rst", keep_warnings=True,
                        directives=tives, extlinks={'issue': ('http://%s', '_issue_')})

        temp = get_temp_folder(__file__, "temp_only")
        with open(os.path.join(temp, "out_cmdref.rst"), "w", encoding="utf8") as f:
            f.write(text)

        t1 = "only for rst"
        if t1 not in text:
            raise Exception(text)
        t1 = "only for html"
        if t1 in text:
            raise Exception(text)

        text = rst2html(content,  # fLOG=fLOG,
                        writer="html", keep_warnings=True,
                        directives=tives, extlinks={'issue': ('http://%s', '_issue_')})

        temp = get_temp_folder(__file__, "temp_only")
        with open(os.path.join(temp, "out_cmdref.rst"), "w", encoding="utf8") as f:
            f.write(text)

        t1 = "only for rst"
        if t1 in text:
            raise Exception(text)
        t1 = "only for html"
        if t1 not in text:
            raise Exception(text)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:51,代码来源:test_rst_builder.py

示例5: test_auc_multi_file

    def test_auc_multi_file(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        t1 = get_temp_folder(__file__, "temp_multi_answers")
        t2 = get_temp_folder(__file__, "temp_multi_scores")
        t3 = get_temp_folder(__file__, "temp_multi_scores2")
        truth = os.path.join(
            t1, "..", "data", "tbl_test_dossier.Y.dummy.truth.txt")
        ans = os.path.join(t1, "..", "data", "tbl_test_dossier.Y.dummy.txt")
        f1 = "answer.txt"
        f2 = "answer.txt"
        shutil.copy(truth, os.path.join(t1, f1))
        shutil.copy(ans, os.path.join(t2, f2))

        with open(truth, "r") as f:
            lines = [_.strip("\r\n ").split("\t") for _ in f.readlines()]
        lines = [[l[0], l[1], "1.0", "1.0"] for l in lines]
        f3 = "answer.txt"
        with open(os.path.join(t3, f3), "w") as f:
            f.write("\n".join("\t".join(_) for _ in lines))

        temp = get_temp_folder(__file__, "temp_multi_out")

        # =
        out = os.path.join(temp, "outpute.txt")
        private_codalab_wrapper_multi_classification(AUC_multi_multi,
                                                     ["orientation", "nature"],
                                                     t1, t3, output=out)
        assert os.path.exists(out)
        with open(out, "r") as f:
            code = f.read()

        self.assertEqual(
            code, "orientation_ERR:0.0\norientation_AUC:1.0\nnature_ERR:0.0\nnature_AUC:1.0")

        # dummy
        fLOG("------------ dummy")
        out = os.path.join(temp, "outputd.txt")
        private_codalab_wrapper_multi_classification(AUC_multi_multi,
                                                     ["orientation", "nature"],
                                                     t1, t2, output=out, ignored=["nul"])
        assert os.path.exists(out)
        with open(out, "r") as f:
            code = f.read()
        fLOG("**", code)

        self.assertEqual(
            code, "orientation_ERR:0.7183754333828628\norientation_AUC:0.5862428771453444\nnature_ERR:0.8236750866765725\nnature_AUC:0.5160556240766593")
开发者ID:sdpython,项目名称:ensae_projects,代码行数:51,代码来源:test_competitions.py

示例6: test_notebook_runner_2a_ml

    def test_notebook_runner_2a_ml(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        from ensae_teaching_cs.automation.notebook_test_helper import ls_notebooks, execute_notebooks, clean_function_1a
        from ensae_teaching_cs.data import simple_database
        temp = get_temp_folder(__file__, "temp_notebook2a_ml4")
        keepnote = ls_notebooks("td2a_ml")
        keepnote = [_ for _ in keepnote if "overfitting" in _]
        shutil.copy(simple_database(), temp)

        def filter(i, n):
            if "SNCF" in n:
                return False
            if "Scraping" in n:
                return False
            if "deep_python" in n:
                return False
            if "h2o" in n:
                # h2o is not working from a virtual environment
                return False
            if "td2a" in os.path.split(n)[-1]:
                # already tested by others tests
                return False
            if "libraries" in n:
                return False
            return True

        execute_notebooks(temp, keepnote, filter, fLOG=fLOG,
                          clean_function=clean_function_1a,
                          dump=ensae_teaching_cs)
开发者ID:sdpython,项目名称:ensae_teaching_cs,代码行数:32,代码来源:test_LONG_2A_notebook_ml4.py

示例7: test_join_multiple2

    def test_join_multiple2(self):
        fLOG(__file__, self._testMethodName, OutputPrint=__name__ == "__main__")
        filename = os.path.join(os.path.split(
            __file__)[0], "data", "database_linked.zip")
        temp = get_temp_folder(__file__, "temp_join_multiple2")
        filename = unzip(filename, temp)
        assert os.path.exists(filename)

        db = Database(filename, LOG=fLOG)
        db.connect()

        where = {"bucket": ("==", "bu###1")}
        n1 = db.JoinTreeNode("profile_QSSH", where=where,
                             parent_key="query", key="query")
        n2 = db.JoinTreeNode("url_QSSH", where=where,
                             parent_key=('url', 'pos'), key=('url', 'pos'))
        n1.append(n2)

        sql, fields = db.inner_joins(n1, execute=False, create_index=False)

        view = db.execute_view(sql)
        assert view == [('facebbooklogin', 1, 0, 'bu###1', 86, 0,
                         'digg.com/security/Hackers_Put_Social_Networks_In_Crosshairs',
                         'digg.com/security/Hackers_Put_Social_Networks_In_Crosshairs',
                         1, 0, 1, 1, 0, 0, 0, 0)]
        assert "WHERE" in sql

        db.close()
开发者ID:sdpython,项目名称:pyensae,代码行数:28,代码来源:test_database_join_multiple.py

示例8: test_folium

    def test_folium(self):
        temp = get_temp_folder(__file__, "temp_folium")
        outfile = os.path.join(temp, "osm.map")

        map_osm = folium.Map(location=[48.85, 2.34])
        map_osm.save(outfile=outfile)
        self.assertTrue(os.path.exists(outfile))
开发者ID:sdpython,项目名称:ensae_teaching_cs,代码行数:7,代码来源:test_modules_import.py

示例9: test_notebook_js

    def test_notebook_js(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        path = os.path.abspath(os.path.split(__file__)[0])
        fold = os.path.normpath(os.path.join(path, "notebooks_js"))
        nbs = [os.path.join(fold, _)
               for _ in os.listdir(fold) if ".ipynb" in _]
        formats = ["slides", "present", "ipynb", "html",
                   "python", "rst", "pdf"]
        if sys.platform.startswith("win"):
            formats.append("docx")

        temp = get_temp_folder(__file__, "temp_nb_bug_js")

        res = process_notebooks(nbs, temp, temp, formats=formats)
        fLOG("*****", len(res))
        for _ in res:
            if not os.path.exists(_[0]):
                raise Exception(_[0])

        check = os.path.join(temp, "using_qgrid_with_jsdf.tex")
        with open(check, "r", encoding="utf8") as f:
            content = f.read()
        if "\\section{" not in content:
            raise Exception(content)
        checks = [os.path.join(temp, "reveal.js"),
                  os.path.join(temp, "require.js")]
        for check in checks:
            if not os.path.exists(check):
                raise Exception(check)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:32,代码来源:test_notebooks_bug_js.py

示例10: test_sphinx_ext_video_latex

    def test_sphinx_ext_video_latex(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        temp = get_temp_folder(__file__, "temp_sphinx_ext_video_latex")

        fLOG('custom app init')
        src_ = self.setup_format(temp)
        app = CustomSphinxApp(src_, temp, buildername="latex")
        fLOG('custom app build')
        app.build()
        fLOG('custom app done')

        index = os.path.join(temp, "pyq-video.tex")
        self.assertExists(index)
        with open(index, "r", encoding="utf-8") as f:
            content = f.read()
        self.assertNotIn("unable to find", content)
        self.assertIn('mur.mp4}', content)
        index = os.path.join(temp, "mur.mp4")
        self.assertExists(index)
        index = os.path.join(temp, "jol", "mur2.mp4")
        self.assertExists(index)
        index = os.path.join(temp, "jol", 'im', "mur3.mp4")
        self.assertExists(index)

        if is_travis_or_appveyor() not in ('travis', 'appveyor'):
            latex = find_latex_path()
            fLOG("latex-compile", latex)
            compile_latex_output_final(temp, latex, doall=True)
            fLOG("compilatione done")
            index = os.path.join(temp, "pyq-video.pdf")
            self.assertExists(index)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:35,代码来源:test_video_extension.py

示例11: test_example_pydy

    def test_example_pydy(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        temp = get_temp_folder(__file__, "temp_example_pydy")
        fix_tkinter_issues_virtualenv()
        import matplotlib.pyplot as plt
        fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(8, 8))
        try:
            example_pydy(ax=ax)
        except Exception as e:
            if 'can only concatenate list (not "tuple") to list' in str(e):
                warnings.warn("Pydy needs to be updated for Python 3.7")
                return
            else:
                raise e
        self.assertNotEmpty(ax)
        img = os.path.join(temp, "img.png")
        fig.savefig(img)
        self.assertExists(img)
        if __name__ == "__main__":
            fig.show()
        plt.close('all')
        fLOG("end")
开发者ID:sdpython,项目名称:jupytalk,代码行数:26,代码来源:test_pydata2016_pydy.py

示例12: test_notebook_raw

    def test_notebook_raw(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        path = os.path.abspath(os.path.split(__file__)[0])
        fold = os.path.normpath(os.path.join(path, "data"))
        nbs = [os.path.join(fold, _)
               for _ in os.listdir(fold) if "TD_2A" in _]
        self.assertGreater(len(nbs), 0)
        formats = ["latex", "present", "ipynb", "html",
                   "python", "rst", "pdf"]
        if sys.platform.startswith("win"):
            formats.append("docx")

        temp = get_temp_folder(__file__, "temp_nb_bug_raw")

        if is_travis_or_appveyor() in ('travis', 'appveyor'):
            return

        res = process_notebooks(nbs, temp, temp, formats=formats)
        fLOG("*****", len(res))
        for _ in res:
            fLOG(_)
            self.assertExists(_[0])

        check = os.path.join(temp, "TD_2A_Eco_Web_Scraping.tex")
        with open(check, "r", encoding="utf8") as f:
            content = f.read()
        if "\\begin{verbatim" not in content:
            raise Exception(content)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:31,代码来源:test_notebooks_bug_raw.py

示例13: test_profiling

    def test_profiling(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        temp = get_temp_folder(__file__, "temp_profiling")
        data = os.path.join(temp, "..", "data", "sample1000.txt")
        with open(data, "r", encoding="utf-8") as f:
            lines = [_.strip(" \n\r\t") for _ in f.readlines()]

        def profile_exe():
            res = self.gain_dynamique_moyen_par_mot(lines, [1.0] * len(lines))
            return res

        def prof(n, show):
            pr = cProfile.Profile()
            pr.enable()
            profile_exe()
            pr.disable()
            s = io.StringIO()
            ps = pstats.Stats(pr, stream=s).sort_stats('cumulative')
            ps.print_stats()
            rem = os.path.normpath(os.path.join(temp, "..", "..", ".."))
            res = s.getvalue().replace(rem, "")
            if show:
                fLOG(res)
            with open(os.path.join(temp, "profiling%d.txt" % n), "w") as f:
                f.write(res)
        prof(1, show=False)
        prof(2, show=True)
开发者ID:sdpython,项目名称:mlstatpy,代码行数:31,代码来源:test_completion_profiling.py

示例14: a_test_notebook_runner

    def a_test_notebook_runner(self, name, folder, valid=None, copy_folder=None):
        temp = get_temp_folder(__file__, "temp_notebook_123_{0}".format(name))
        doc = os.path.join(temp, "..", "..", "..", "_doc", "notebooks", folder)
        if not os.path.exists(doc):
            raise FileNotFoundError(doc)
        keepnote = [os.path.join(doc, _) for _ in os.listdir(doc) if name in _]
        self.assertTrue(len(keepnote) > 0)

        if copy_folder is not None:
            if not os.path.exists(copy_folder):
                raise FileNotFoundError(copy_folder)
            dest = os.path.split(copy_folder)[-1]
            dest = os.path.join(temp, dest)
            if not os.path.exists(dest):
                os.mkdir(dest)
            synchronize_folder(copy_folder, dest, fLOG=fLOG)

        import pyquickhelper
        import jyquickhelper
        import pyensae
        import ensae_teaching_cs
        add_path = get_additional_paths(
            [jyquickhelper, pyquickhelper, pyensae, ensae_teaching_cs])
        res = execute_notebook_list(
            temp, keepnote, additional_path=add_path, valid=valid)
        execute_notebook_list_finalize_ut(
            res, fLOG=fLOG, dump=ensae_teaching_cs)
开发者ID:sdpython,项目名称:ensae_teaching_cs,代码行数:27,代码来源:test_LONG_1_2_3_coverage_notebook6_201710b.py

示例15: test_module_c

    def test_module_c(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        path = os.path.abspath(os.path.split(__file__)[0])
        file = os.path.join(path, "data", "pyd",
                            "stdchelper.cp37-win_amd64.pyd")
        self.assertExists(file)
        mo = import_module(
            None, file, fLOG, additional_sys_path=None, first_try=True)
        self.assertIsInstance(mo, tuple)
        self.assertEqual(len(mo), 2)
        self.assertTrue(hasattr(mo[0], '__doc__'))
        if 'stdchelper' in sys.modules:
            del sys.modules['stdchelper']

        temp = get_temp_folder(__file__, "temp_module_c")
        store_obj = {}
        actions = copy_source_files(os.path.dirname(file), temp, fLOG=fLOG)
        store_obj = {}
        indexes = {}
        add_file_rst(temp, store_obj, actions, fLOG=fLOG,
                     rootrep=("module_c.", ""), indexes=indexes)
        self.assertNotEmpty(store_obj)
        self.assertEqual(len(store_obj), 4)
        if len(actions) != 2:
            raise Exception("{0}\n{1}".format(
                len(actions), "\n".join(str(_) for _ in actions)))
        self.assertEqual(len(indexes), 1)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:30,代码来源:test_module_c.py


注:本文中的pyquickhelper.pycode.get_temp_folder函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。