mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
Merge pull request #1168 from fperez/nbscript
Add --script/--no-script flags as shorthands for the NotebookManager.save_script option.
This commit is contained in:
commit
e98c8f7fd0
@ -52,7 +52,7 @@ from .handlers import (LoginHandler, LogoutHandler,
|
||||
)
|
||||
from .notebookmanager import NotebookManager
|
||||
|
||||
from IPython.config.application import catch_config_error
|
||||
from IPython.config.application import catch_config_error, boolean_flag
|
||||
from IPython.core.application import BaseIPythonApplication
|
||||
from IPython.core.profiledir import ProfileDir
|
||||
from IPython.lib.kernel import swallow_argv
|
||||
@ -157,10 +157,15 @@ flags['read-only'] = (
|
||||
"""
|
||||
)
|
||||
|
||||
# Add notebook manager flags
|
||||
flags.update(boolean_flag('script', 'NotebookManager.save_script',
|
||||
'Auto-save a .py script everytime the .ipynb notebook is saved',
|
||||
'Do not auto-save .py scripts for every notebook'))
|
||||
|
||||
# the flags that are specific to the frontend
|
||||
# these must be scrubbed before being passed to the kernel,
|
||||
# or it will raise an error on unrecognized flags
|
||||
notebook_flags = ['no-browser', 'no-mathjax', 'read-only']
|
||||
notebook_flags = ['no-browser', 'no-mathjax', 'read-only', 'script', 'no-script']
|
||||
|
||||
aliases = dict(ipkernel_aliases)
|
||||
|
||||
|
@ -27,12 +27,10 @@ from IPython.config.configurable import LoggingConfigurable
|
||||
from IPython.nbformat import current
|
||||
from IPython.utils.traitlets import Unicode, List, Dict, Bool
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Code
|
||||
# Classes
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
class NotebookManager(LoggingConfigurable):
|
||||
|
||||
notebook_dir = Unicode(os.getcwd(), config=True, help="""
|
||||
@ -40,10 +38,12 @@ class NotebookManager(LoggingConfigurable):
|
||||
""")
|
||||
|
||||
save_script = Bool(False, config=True,
|
||||
help="""Also save notebooks as a Python script.
|
||||
help="""Automatically create a Python script when saving the notebook.
|
||||
|
||||
For easier use of import/%loadpy across notebooks, a <notebook-name>.py
|
||||
script will be created next to any <notebook-name>.ipynb on each save.
|
||||
For easier use of import, %run and %loadpy across notebooks, a
|
||||
<notebook-name>.py script will be created next to any
|
||||
<notebook-name>.ipynb on each save. This can also be set with the
|
||||
short `--script` flag.
|
||||
"""
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user