mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-07 13:07:22 +08:00
Merge pull request #3500 from ipython/nbconvert
Merge nbconvert into IPython
This commit is contained in:
commit
13c93844ed
35
IPython/nbconvert/exporters/python.py
Normal file
35
IPython/nbconvert/exporters/python.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""
|
||||
Python exporter which exports Notebook code into a PY file.
|
||||
"""
|
||||
#-----------------------------------------------------------------------------
|
||||
# Copyright (c) 2013, the IPython Development Team.
|
||||
#
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
#
|
||||
# The full license is in the file COPYING.txt, distributed with this software.
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Imports
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
from IPython.utils.traitlets import Unicode
|
||||
|
||||
from .exporter import Exporter
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Classes
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
class PythonExporter(Exporter):
|
||||
"""
|
||||
Exports a Python code file.
|
||||
"""
|
||||
|
||||
file_extension = Unicode(
|
||||
'py', config=True,
|
||||
help="Extension of the file that should be written to disk")
|
||||
|
||||
template_file = Unicode(
|
||||
'python', config=True,
|
||||
help="Name of the template file to use")
|
@ -166,6 +166,8 @@ have['jinja2'] = test_for('jinja2')
|
||||
have['wx'] = test_for('wx')
|
||||
have['wx.aui'] = test_for('wx.aui')
|
||||
have['azure'] = test_for('azure')
|
||||
have['sphinx'] = test_for('sphinx')
|
||||
have['markdown'] = test_for('markdown')
|
||||
|
||||
min_zmq = (2,1,11)
|
||||
|
||||
@ -305,6 +307,9 @@ def make_exclude():
|
||||
if not have['azure']:
|
||||
exclusions.append(ipjoin('html', 'services', 'notebooks', 'azurenbmanager'))
|
||||
|
||||
if not all((have['pygments'], have['jinja2'], have['markdown'], have['sphinx'])):
|
||||
exclusions.append(ipjoin('nbconvert'))
|
||||
|
||||
# This is needed for the reg-exp to match on win32 in the ipdoctest plugin.
|
||||
if sys.platform == 'win32':
|
||||
exclusions = [s.replace('\\','\\\\') for s in exclusions]
|
||||
@ -440,7 +445,7 @@ def make_runners(inc_slow=False):
|
||||
|
||||
# Packages to be tested via nose, that only depend on the stdlib
|
||||
nose_pkg_names = ['config', 'core', 'extensions', 'lib', 'terminal',
|
||||
'testing', 'utils', 'nbformat' ]
|
||||
'testing', 'utils', 'nbformat']
|
||||
|
||||
if have['qt']:
|
||||
nose_pkg_names.append('qt')
|
||||
@ -454,6 +459,9 @@ def make_runners(inc_slow=False):
|
||||
if inc_slow:
|
||||
nose_pkg_names.append('parallel')
|
||||
|
||||
if all((have['pygments'], have['jinja2'], have['markdown'], have['sphinx'])):
|
||||
nose_pkg_names.append('nbconvert')
|
||||
|
||||
# For debugging this code, only load quick stuff
|
||||
#nose_pkg_names = ['core', 'extensions'] # dbg
|
||||
|
||||
|
1
setup.py
1
setup.py
@ -278,6 +278,7 @@ if 'setuptools' in sys.modules:
|
||||
doc = 'Sphinx>=0.3',
|
||||
test = 'nose>=0.10.1',
|
||||
notebook = ['tornado>=2.0', 'pyzmq>=2.1.11', 'jinja2'],
|
||||
nbconvert = ['pygments', 'markdown', 'jinja2', 'Sphinx>=0.3']
|
||||
)
|
||||
requires = setup_args.setdefault('install_requires', [])
|
||||
setupext.display_status = False
|
||||
|
@ -151,6 +151,8 @@ def find_package_data():
|
||||
'IPython.testing.plugin' : ['*.txt'],
|
||||
'IPython.html' : ['templates/*'] + static_data,
|
||||
'IPython.qt.console' : ['resources/icon/*.svg'],
|
||||
'IPython.nbconvert.templates' : ['*.tpl', 'latex/*.tpl',
|
||||
'latex/skeleton/*.tplx', 'skeleton/*']
|
||||
}
|
||||
return package_data
|
||||
|
||||
@ -320,7 +322,7 @@ def find_scripts(entry_points=False, suffix=''):
|
||||
'iplogger%s = IPython.parallel.apps.iploggerapp:launch_new_instance',
|
||||
'ipcluster%s = IPython.parallel.apps.ipclusterapp:launch_new_instance',
|
||||
'iptest%s = IPython.testing.iptest:main',
|
||||
'irunner%s = IPython.lib.irunner:main'
|
||||
'irunner%s = IPython.lib.irunner:main',
|
||||
]]
|
||||
gui_scripts = []
|
||||
scripts = dict(console_scripts=console_scripts, gui_scripts=gui_scripts)
|
||||
@ -352,7 +354,8 @@ def check_for_dependencies():
|
||||
print_line, print_raw, print_status,
|
||||
check_for_sphinx, check_for_pygments,
|
||||
check_for_nose, check_for_pexpect,
|
||||
check_for_pyzmq, check_for_readline
|
||||
check_for_pyzmq, check_for_readline,
|
||||
check_for_jinja2, check_for_markdown
|
||||
)
|
||||
print_line()
|
||||
print_raw("BUILDING IPYTHON")
|
||||
@ -370,6 +373,8 @@ def check_for_dependencies():
|
||||
check_for_pexpect()
|
||||
check_for_pyzmq()
|
||||
check_for_readline()
|
||||
check_for_jinja2()
|
||||
check_for_markdown()
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# VCS related
|
||||
|
Loading…
Reference in New Issue
Block a user