diff --git a/_doc/notebooks/having_a_form_in_a_notebook.ipynb b/_doc/notebooks/having_a_form_in_a_notebook.ipynb index 9e7e6158..2eb4c9af 100644 --- a/_doc/notebooks/having_a_form_in_a_notebook.ipynb +++ b/_doc/notebooks/having_a_form_in_a_notebook.ipynb @@ -1116,32 +1116,6 @@ "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" - }, - "widgets": { - "state": { - "6f6cf4a1f7df4a99ba95db615ec86dff": { - "views": [ - { - "cell_index": 20 - } - ] - }, - "c67410ee5aa443b9a6cb53d4f46becec": { - "views": [ - { - "cell_index": 20 - } - ] - }, - "dd3c00717e9d48b99bb5e34462b15fa0": { - "views": [ - { - "cell_index": 20 - } - ] - } - }, - "version": "1.2.0" } }, "nbformat": 4, diff --git a/_unittests/ut_helpgen/notebooks/td2a_cenonce_session_3A.ipynb b/_unittests/ut_helpgen/notebooks/td2a_cenonce_session_3A.ipynb index b24fed5a..95d872cf 100644 --- a/_unittests/ut_helpgen/notebooks/td2a_cenonce_session_3A.ipynb +++ b/_unittests/ut_helpgen/notebooks/td2a_cenonce_session_3A.ipynb @@ -1636,18 +1636,6 @@ "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.5" - }, - "widgets": { - "state": { - "37694361e5da4eb38daa525f8bb2117c": { - "views": [ - { - "cell_index": 9 - } - ] - } - }, - "version": "1.2.0" } }, "nbformat": 4, diff --git a/_unittests/ut_helpgen/test_notebooks_bug.py b/_unittests/ut_helpgen/test_notebooks_bug.py index cdf60c2d..dd4d4629 100644 --- a/_unittests/ut_helpgen/test_notebooks_bug.py +++ b/_unittests/ut_helpgen/test_notebooks_bug.py @@ -5,7 +5,6 @@ import os import unittest import re -from pyquickhelper.loghelper import fLOG from pyquickhelper.helpgen.sphinx_main import process_notebooks from pyquickhelper.pycode import is_travis_or_appveyor, get_temp_folder, ExtTestCase @@ -13,36 +12,24 @@ class TestNoteBooksBug(ExtTestCase): def test_regex(self): - fLOG( - __file__, - self._testMethodName, - OutputPrint=__name__ == "__main__") exp = re.compile(r"(.{3}[\\]\$)") s = ": [ ['$'," - fLOG(s) r = exp.finditer(s) nb = 0 for _ in r: - fLOG("1", _.groups()) nb += 1 nb1 = nb s = r"\def\PYZdl{\char`\$}" - fLOG(s) r = exp.finditer(s) nb = 0 for _ in r: - fLOG("2", _.groups()) nb += 1 self.assertEqual(nb1, 0) self.assertTrue(nb > 0) def test_notebook(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")) nbs = [os.path.join(fold, _) @@ -55,7 +42,6 @@ def test_notebook(self): return res = process_notebooks(nbs, temp, temp, formats=formats) - fLOG("*****", len(res)) for _ in res: if not os.path.exists(_[0]): raise Exception(_[0]) @@ -67,10 +53,6 @@ def test_notebook(self): raise Exception(content) def test_notebook_html(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")) nbs = [os.path.join(fold, _) @@ -83,16 +65,11 @@ def test_notebook_html(self): return res = process_notebooks(nbs, temp, temp, formats=formats) - fLOG("*****", len(res)) for _ in res: if not os.path.exists(_[0]): raise Exception(_[0]) def test_notebook_slides(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")) nbs = [os.path.join(fold, _) @@ -105,7 +82,6 @@ def test_notebook_slides(self): return res = process_notebooks(nbs, temp, temp, formats=formats) - fLOG("*****", len(res)) for _ in res: if not os.path.exists(_[0]): raise Exception(_[0]) @@ -117,10 +93,6 @@ def test_notebook_slides(self): raise Exception(check) def test_notebook_pdf(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")) nbs = [os.path.join(fold, _) @@ -137,9 +109,7 @@ def test_notebook_pdf(self): return res = process_notebooks(nbs, temp, temp, formats=formats) - fLOG("*****", len(res)) for _ in res: - fLOG(_) self.assertExists(_[0]) check = os.path.join(temp, "td1a_correction_session4.tex") @@ -150,4 +120,4 @@ def test_notebook_pdf(self): if __name__ == "__main__": - unittest.main() + unittest.main(verbosity=2) diff --git a/src/pyquickhelper/ipythonhelper/notebook_helper.py b/src/pyquickhelper/ipythonhelper/notebook_helper.py index 94ffe69f..cd960822 100644 --- a/src/pyquickhelper/ipythonhelper/notebook_helper.py +++ b/src/pyquickhelper/ipythonhelper/notebook_helper.py @@ -451,7 +451,8 @@ def remove_execution_number(infile, outfile=None, encoding="utf-8", indent=2, ru @param indent indentation @param rule determines the rule which specifies execution numbers, 'None' for None, 'int' for consectuive integers numbers. - @return modified string or None if outfile is not None and the file was not modified + @return modified string or None if outfile is not None + and the file was not modified .. todoext:: :title: remove execution number from notebook facilitate git versionning @@ -465,7 +466,8 @@ def remove_execution_number(infile, outfile=None, encoding="utf-8", indent=2, ru Remove execution number from the notebook to avoid commiting changes only about those numbers - `notebook 5.1.0 `_ + `notebook 5.1.0 + `_ introduced changes which are incompatible with leaving the cell executing number empty. """ @@ -497,9 +499,17 @@ def fixup(adict, k, v, cellno=0, outputs="outputs"): outputs=outputs) return cellno + def widget(adict): + metadata = adict.get('metadata', None) + if metadata is None: + return + if 'widgets' in metadata: + del metadata['widgets'] + content = read_content_ufs(infile) js = json.loads(content) fixup(js, "execution_count", None) + widget(js) st = StringIO() json.dump(js, st, indent=indent, sort_keys=True) res = st.getvalue() diff --git a/src/pyquickhelper/sphinxext/sphinximages/sphinxtrib/images.py b/src/pyquickhelper/sphinxext/sphinximages/sphinxtrib/images.py index 3280bfb7..857fac07 100644 --- a/src/pyquickhelper/sphinxext/sphinximages/sphinxtrib/images.py +++ b/src/pyquickhelper/sphinxext/sphinximages/sphinxtrib/images.py @@ -323,12 +323,6 @@ def configure_backend(app): # because sphinx try to make a pickle from it. app.sphinxtrib_images_backend = backend - logger = logging.getLogger("image") - logger.info( - 'Initiated images backend: %s:%s', - backend.__class__.__module__, - backend.__class__.__name__) - def backend_methods(node, output_type): "local function" def backend_method(f):