本文整理汇总了Python中pyquickhelper.loghelper.flog.fLOG函数的典型用法代码示例。如果您正苦于以下问题:Python fLOG函数的具体用法?Python fLOG怎么用?Python fLOG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fLOG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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)
示例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)
示例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))
示例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))
示例7: test_post_parse
def test_post_parse(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
directives.register_directive("runpython", RunPythonDirective)
示例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)
示例9: test_post_parse_sn
def test_post_parse_sn(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
directives.register_directive("video", VideoDirective)
示例10: test_post_parse_sn
def test_post_parse_sn(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
register_canonical_role("githublink", githublink_role)
示例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)
示例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)
示例13: test_numpy_random
def test_numpy_random(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
np.random.seed(42)
示例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 "))
示例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