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


Python ExecutePreprocessor.allow_errors方法代码示例

本文整理汇总了Python中nbconvert.preprocessors.ExecutePreprocessor.allow_errors方法的典型用法代码示例。如果您正苦于以下问题:Python ExecutePreprocessor.allow_errors方法的具体用法?Python ExecutePreprocessor.allow_errors怎么用?Python ExecutePreprocessor.allow_errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nbconvert.preprocessors.ExecutePreprocessor的用法示例。


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

示例1: sorted

# 需要导入模块: from nbconvert.preprocessors import ExecutePreprocessor [as 别名]
# 或者: from nbconvert.preprocessors.ExecutePreprocessor import allow_errors [as 别名]
for fname in sorted(glob.glob1(src_dir, '*.ipynb')):
    basename = fname[:-6]
    output_ipynb_fname = os.path.join(target_dir, fname)
    output_rst_fname = os.path.join(target_dir, basename + '.rst')

    print 'Running', fname
    with open(os.path.join(src_dir, fname), 'r') as f:
        notebook = reads(f.read())

    # The first line of the tutorial file should give the title
    title = notebook.cells[0]['source'].split('\n')[0].strip('# ')
    tutorials.append((basename, title))

    # Execute the notebook
    preprocessor = ExecutePreprocessor()
    preprocessor.allow_errors = True
    notebook, _ = preprocessor.preprocess(notebook,
                                          {'metadata': {'path': src_dir}})

    print 'Saving notebook and converting to RST'
    exporter = NotebookExporter()
    output, _ = exporter.from_notebook_node(notebook)
    with codecs.open(output_ipynb_fname, 'w', encoding='utf-8') as f:
        f.write(output)

    # Insert a note about ipython notebooks with a download link
    note = deindent(u'''
    .. only:: html

        .. |launchbinder| image:: http://mybinder.org/badge.svg
        .. _launchbinder: http://mybinder.org:/repo/brian-team/brian2-binder/notebooks/tutorials/{tutorial}.ipynb
开发者ID:brian-team,项目名称:brian2,代码行数:33,代码来源:build_tutorials.py


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