• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python flog.fLOG函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_thumbnail

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

        from docutils import nodes as skip_

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

                    before

                    .. thumbnail:: http://www.xavierdupre.fr/app/pyquickhelper/helpsphinx/_static/project_ico.png
                        :width: 10
                        :height: 20
                        :download: 1

                    after

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

        logger2 = logging.getLogger("video")

        log_capture_string = StringIO()
        ch = logging.StreamHandler(log_capture_string)
        ch.setLevel(logging.DEBUG)
        logger2.addHandler(ch)
        with warnings.catch_warnings(record=True):
            html = rst2html(content,  # fLOG=fLOG,
                            writer="custom", keep_warnings=True,
                            directives=None)

        warns = log_capture_string.getvalue()
        if warns:
            raise Exception(warns)

        t1 = "this code shoud not appear"
        if t1 in html:
            raise Exception(html)

        t1 = "this code shoud appear"
        if t1 not in html:
            raise Exception(html)

        t1 = "_images"
        if t1 not in html:
            raise Exception(html)

        t1 = "linkedin"
        if t1 in html:
            raise Exception(html)

        temp = get_temp_folder(__file__, "temp_sphinx_thumbnail")
        with open(os.path.join(temp, "out_image.html"), "w", encoding="utf8") as f:
            f.write(html)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:60,代码来源:test_thumbnail_extension.py


示例2: test_pyensae_links

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

        this = os.path.join(os.path.dirname(__file__),
                            '..', '..', '_doc', 'notebooks')
        checked = 0
        missed = []
        tolook = ['http://files.grouplens.org/datasets/movielens/ml-1m.zip',
                  'http://www.xavierdupre.fr/',
                  'url=\\"http',
                  '\\"Skin_NonSkin.txt\\", website=\\"https://archive.ics',
                  "website='http://telechargement.insee.fr/fichiersdetail",
                  'https://archive.ics.uci.edu/ml/machine-learning-databases']
        for note in explore_folder_iterfile(this, ".*[.]ipynb$", ".ipynb_checkpoints", fullname=True):
            with open(note, 'r', encoding='utf-8') as f:
                content = f.read()
            if "datasource import download_data" in content or "pyensae.download_data(" in content:
                checked += 1
                found = False
                for to in tolook:
                    if to in content:
                        found = True
                if not found:
                    missed.append(note)
        self.assertGreater(checked, 1)
        self.assertEmpty(missed)
开发者ID:sdpython,项目名称:ensae_teaching_cs,代码行数:29,代码来源:test_pyensae_links.py


示例3: test_param_sphinx

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

        from docutils import nodes as skip_

        content = """
                    Addition 4

                    :param a: parameter a
                    :param b: parameter b

                    :returns: ``a+b``
                    """.replace("                    ", "")
        html = rst2html(content,  # fLOG=fLOG,
                        writer="custom", keep_warnings=True,
                        directives=None, layout="sphinx")

        temp = get_temp_folder(__file__, "temp_param_sphinx")
        with open(os.path.join(temp, "out_param_sphinx.html"), "w", encoding="utf8") as f:
            f.write(html)

        t1 = ":param a:"
        if t1 in html:
            raise Exception(html)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:27,代码来源:test_doc_bug.py


示例4: test_parse_readme_cb

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

        fold = os.path.dirname(os.path.abspath(__file__))
        readme = os.path.join(fold, "data", "README.rst")
        fLOG(readme)
        assert os.path.exists(readme)
        with open(readme, "r", encoding="utf8") as f:
            content = f.read()
        r = parse_markdown(content)
        if "<p>.. _l-README:</p>" not in str(r):
            m = [ord(c) for c in content]
            m = ",".join(str(_) for _ in m[:20])
            raise Exception("IN\n{0}\nOUT:{1}".format(m, str(r)))

        ht = rst2html(content)
        # fLOG(ht)
        assert len(ht) > 0

        spl = content.split("\n")
        r = list(yield_sphinx_only_markup_for_pipy(spl))
        assert len(r) == len(spl)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:25,代码来源:test_markdown_helper.py


示例5: test_enumerate_notebooks_link

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

        this = os.path.abspath(os.path.dirname(__file__))
        nb_folder = os.path.join(this, "..", "..", "_doc", "notebooks")
        self.assertTrue(os.path.exists(nb_folder))
        nb_doc = os.path.join(this, "..", "..", "_doc", "sphinxdoc", "source")
        self.assertTrue(os.path.exists(nb_doc))
        nb = 0
        counts = {'title': 0}
        nbfound = set()
        for r in enumerate_notebooks_link(nb_folder, nb_doc):
            rl = list(r)
            rl[0] = None if r[0] is None else os.path.split(r[0])[-1]
            rl[1] = os.path.split(r[1])[-1]
            nb += 1
            m = rl[2]
            counts[m] = counts.get(m, 0) + 1
            self.assertTrue(r[-2] is None or isinstance(r[-2], str))
            self.assertTrue(r[-1] is None or isinstance(r[-1], str))
            if r[-1] is not None:
                counts["title"] += 1
            nbfound.add(rl[1])
        self.assertTrue(counts.get("ref", 0) > 0)
        self.assertIn(counts.get(None, 0), (0, 10))
        self.assertTrue(counts["title"] > 0)
        self.assertTrue(len(nbfound) > 8)
        # self.assertTrue(counts.get("refn", 0) > 0)
        self.assertIn(counts.get("toctree", 0), (0, 14))
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:32,代码来源:test_stat_helper.py


示例6: test_rst2html_png

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

        if is_travis_or_appveyor() in ('travis', 'appveyor'):
            # It requires latex.
            return

        temp = get_temp_folder(__file__, "temp_rst2html_png")
        rst = os.path.join(os.path.abspath(
            os.path.dirname(__file__)), "data", "hermionne.rst")
        with open(rst, "r", encoding="utf-8") as f:
            content = f.read()

        text = rst2html(content)

        ji = os.path.join(temp, "out.html")
        with open(ji, "w", encoding="utf-8") as f:
            f.write(text)
        text2 = rst2html(content, layout="sphinx")
        ji = os.path.join(temp, "out_sphinx.html")
        with open(ji, "w", encoding="utf-8") as f:
            f.write(text)
        self.assertTrue(len(text2) > len(text))
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:26,代码来源:test_rst2html.py


示例7: test_post_parse

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

        directives.register_directive("runpython", RunPythonDirective)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:7,代码来源:test_runpython_extension.py


示例8: test_rst2html_autoclass

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

        if is_travis_or_appveyor() in ('travis', 'appveyor'):
            # It requires latex.
            return

        if sys.version_info[:2] <= (2, 7):
            # i don't want to fix it for Python 2.7
            return

        content = """
                    ======
                    title1
                    ======

                    .. autoclass:: pyquickhelper.sphinxext.sphinx_runpython_extension.RunPythonDirective
                        :members:

        """.replace("                    ", "")

        temp = get_temp_folder(__file__, "temp_rst2html_autoclass")
        text = rst2html(content, outdir=temp, layout="sphinx", writer="rst")
        ji = os.path.join(temp, "out.rst")
        with open(ji, "w", encoding="utf-8") as f:
            f.write(text)
        self.assertIn("* ``:indent:<int>`` to indent the output", text)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:30,代码来源:test_rst2html_toc.py


示例9: test_post_parse_sn

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

        directives.register_directive("video", VideoDirective)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:7,代码来源:test_video_extension.py


示例10: test_post_parse_sn

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

        register_canonical_role("githublink", githublink_role)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:7,代码来源:test_githublink_extension.py


示例11: test_post_parse_sn_youtube

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

        directives.register_directive("youtube", YoutubeDirective)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:7,代码来源:test_youtube_extension.py


示例12: test_runpython_image

    def test_runpython_image(self):
        """
        this test also test the extension runpython
        """
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        from docutils import nodes

        class runpythonthis_node(nodes.Structural, nodes.Element):
            pass

        class RunPythonThisDirective (RunPythonDirective):
            runpython_class = runpythonthis_node

        def visit_rp_node(self, node):
            self.body.append("<p><b>visit_rp_node</b></p>")

        def depart_rp_node(self, node):
            self.body.append("<p><b>depart_rp_node</b></p>")

        if "enable_disabled_documented_pieces_of_code" in sys.__dict__:
            raise Exception("this case shoud not be")

        temp = get_temp_folder(__file__, "temp_runpython_image")
        content = """
                    test a directive
                    ================

                    .. runpythonthis::
                        :rst:
                        :showcode:

                        import matplotlib.pyplot as plt
                        fig, ax = plt.subplots(1, 1, figsize=(4, 4))
                        ax.plot([0, 1], [0, 1], '--')
                        if __WD__ is None:
                            raise Exception(__WD__)
                        fig.savefig("__FOLD__/oo.png")

                        text = ".. image:: oo.png\\n    :width: 200px"
                        print(text)

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

        tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node,
                  visit_rp_node, depart_rp_node)]

        html = rst2html(content,  # fLOG=fLOG,
                        writer="custom", keep_warnings=True,
                        directives=tives)

        with open(os.path.join(temp, "out.html"), "w", encoding="utf8") as f:
            f.write(html)
        img = os.path.join(temp, "oo.png")
        self.assertExists(img)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:60,代码来源:test_runpython_extension_image.py


示例13: test_numpy_random

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

        np.random.seed(42)
开发者ID:sdpython,项目名称:ensae_teaching_cs,代码行数:7,代码来源:test_numpy_seed.py


示例14: test__private_migrating_doxygen_doc

    def test__private_migrating_doxygen_doc(self):
        """First line.
        Second line.

        @param  self        self
        """
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        doc = TestHelpGenPrivate.__doc__.split("\n")
        res = _private_migrating_doxygen_doc(doc, 0, "<test>")
        exp = """
                First line.
                Second line.


                :githublink:`%|py|0`
                """.replace("            ", "")
        self.assertEqual("\n".join(res).strip("\n "), exp.strip("\n "))

        doc = TestHelpGenPrivate.test__private_migrating_doxygen_doc.__doc__.split(
            "\n")
        res = _private_migrating_doxygen_doc(doc, 0, "<test>")
        exp = """
                    First line.
                    Second line.

                    :param  self:        self


                    :githublink:`%|py|0`
                """.replace("            ", "")
        self.assertEqual("\n".join(res).strip("\n "), exp.strip("\n "))
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:35,代码来源:test__private_migrating_doxygen_doc.py


示例15: test_sphinx_doc

    def test_sphinx_doc(self):
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")
        path = os.path.split(__file__)[0]
        file = os.path.join(
            path,
            "..",
            "..",
            "src",
            "pyquickhelper",
            "helpgen",
            "utils_sphinx_doc.py")
        assert os.path.exists(file)

        with open(file, "r", encoding="utf8") as f:
            content = f.read()
        stats, newc = utils_sphinx_doc.migrating_doxygen_doc(content, file)
        snewc = newc[:len(newc) // 2]
        assert "pass" in newc
        assert ":param" in newc
        if "@param" in snewc:
            raise Exception(snewc)
        assert "docrows" in stats
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:25,代码来源:test_utils_sphinxdoc.py


示例16: test_rst2html_png_bug

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

        if is_travis_or_appveyor() in ('travis', 'appveyor'):
            # It requires latex.
            return

        if sys.version_info[:2] <= (2, 7):
            # i don't want to fix it for Python 2.7
            return

        temp = get_temp_folder(__file__, "temp_rst2html_png_latex")
        rst = os.path.join(os.path.abspath(
            os.path.dirname(__file__)), "data", "puzzle_girafe.rst")
        with open(rst, "r", encoding="utf-8") as f:
            content = f.read()
        text = rst2html(content, fLOG=fLOG, outdir=temp, warnings_log=True,
                        imgmath_latex_preamble="""
                    \\newcommand{\\acc}[1]{\\left\\{#1\\right\\}}
                    \\newcommand{\\cro}[1]{\\left[#1\\right]}
                    \\newcommand{\\pa}[1]{\\left(#1\\right)}
                    \\newcommand{\\girafedec}[3]{ \\begin{array}{ccccc} #1 &=& #2 &+& #3 \\\\ a' &=& a &-& o  \\end{array}}
                    \\newcommand{\\vecteur}[2]{\\pa{#1,\\dots,#2}}
                    \\newcommand{\\R}[0]{\\mathbb{R}}
                    \\newcommand{\\N}[0]{\\mathbb{N}}
                    """)
        # fLOG(text)
        ji = os.path.join(temp, "out.html")
        with open(ji, "w", encoding="utf-8") as f:
            f.write(text)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:33,代码来源:test_rst2html_latex.py


示例17: test_runpython_numpy

    def test_runpython_numpy(self):
        """
        this test also test the extension runpython
        """
        fLOG(
            __file__,
            self._testMethodName,
            OutputPrint=__name__ == "__main__")

        from docutils import nodes

        if "enable_disabled_documented_pieces_of_code" in sys.__dict__:
            raise Exception("this case shoud not be")

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

                    .. runpythonthis::
                        :setsysvar:
                        :rst:
                        :showcode:
                        :numpy_precision: 2

                        import numpy
                        print(numpy.array([1.123456789, 1.987654321]))
                    """.replace("                    ", "")

        html = rst2html(content,  # fLOG=fLOG,
                        writer="rst", keep_warnings=True)
        if "[1.12 1.99]" not in html:
            raise Exception(html)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:32,代码来源:test_runpython_extension.py


示例18: 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


示例19: test_bokeh

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

        from docutils import nodes as skip_
        from pyquickhelper.sphinxext.bokeh.bokeh_plot import BokehPlotDirective
        self.assertTrue(BokehPlotDirective is not None)

        content = """
                    =======
                    History
                    =======

                    "this code should appear

                    .. bokeh-plot::

                        from bokeh.plotting import figure, output_file, show

                        output_file("temp_unittest.html")

                        x = [1, 2, 3, 4, 5]
                        y = [6, 7, 6, 4, 5]

                        p = figure(title="example_bokeh", plot_width=300, plot_height=300)
                        p.line(x, y, line_width=2)
                        p.circle(x, y, size=10, fill_color="white")

                        show(p)

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

        html = rst2html(content,  # fLOG=fLOG,
                        writer="html", keep_warnings=True,
                        directives=None, layout="sphinx",
                        load_bokeh=True)

        t1 = "this code should appear"
        if t1 not in html:
            raise Exception(html)

        temp = get_temp_folder(__file__, "temp_bokeh_extension")
        with open(os.path.join(temp, "page_bokeh.html"), "w", encoding="utf-8") as f:
            f.write(html)

        if 'Unknown directive type' in html:
            raise Exception(html)

        if '<<string>>#document-<<string>>' in html:
            pass
        else:
            raise Exception(html)

        if 'bokeh-plot-string-inline' not in html:
            raise Exception(html)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:59,代码来源:test_bokeh_extension.py


示例20: test_runpython_process_exception

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

        from docutils import nodes

        class runpythonthis_node(nodes.Structural, nodes.Element):
            pass

        class RunPythonThisDirective (RunPythonDirective):
            runpython_class = runpythonthis_node

        def visit_rp_node(self, node):
            "local function"
            self.body.append("<p><b>visit_rp_node</b></p>")

        def depart_rp_node(self, node):
            self.body.append("<p><b>depart_rp_node</b></p>")

        if "enable_disabled_documented_pieces_of_code" in sys.__dict__:
            raise Exception("this case shoud not be")

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

                    .. runpythonthis::
                        :showcode:
                        :exception:
                        :process:

                        print(u"this code shoud" + u" appear")
                        z = 1/0
                        print(u"this one should" + u" not")
                    """.replace("                    ", "")
        if sys.version_info[0] >= 3:
            content = content.replace('u"', '"')

        tives = [("runpythonthis", RunPythonThisDirective, runpythonthis_node,
                  visit_rp_node, depart_rp_node)]

        html = rst2html(content,  # fLOG=fLOG,
                        writer="custom", keep_warnings=True,
                        directives=tives)

        t2 = "<p>&lt;&lt;&lt;</p>"
        if t2 not in html:
            raise Exception(html)
        t2 = "<p>&gt;&gt;&gt;</p>"
        if t2 not in html:
            raise Exception(html)
        if "ZeroDivisionError" not in html:
            temp = get_temp_folder(
                __file__, "temp_runpython_process_exception")
            with open(os.path.join(temp, "out.html"), "w", encoding="utf8") as f:
                f.write(html)
            raise Exception(html)
开发者ID:sdpython,项目名称:pyquickhelper,代码行数:59,代码来源:test_runpython_extension.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pycode.add_missing_development_version函数代码示例发布时间:2022-05-27
下一篇:
Python loghelper.fLOG函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap