##// END OF EJS Templates
Add --script flag as shorthand for the script autosave notebook option.
Fernando Perez -
Show More
@@ -50,7 +50,7 b' from .handlers import (LoginHandler, LogoutHandler,'
50 MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler,
50 MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler,
51 ShellHandler, NotebookRootHandler, NotebookHandler, RSTHandler
51 ShellHandler, NotebookRootHandler, NotebookHandler, RSTHandler
52 )
52 )
53 from .notebookmanager import NotebookManager
53 from .notebookmanager import NotebookManager, manager_flags
54
54
55 from IPython.config.application import catch_config_error
55 from IPython.config.application import catch_config_error
56 from IPython.core.application import BaseIPythonApplication
56 from IPython.core.application import BaseIPythonApplication
@@ -157,10 +157,12 b" flags['read-only'] = ("
157 """
157 """
158 )
158 )
159
159
160 flags.update(manager_flags)
161
160 # the flags that are specific to the frontend
162 # the flags that are specific to the frontend
161 # these must be scrubbed before being passed to the kernel,
163 # these must be scrubbed before being passed to the kernel,
162 # or it will raise an error on unrecognized flags
164 # or it will raise an error on unrecognized flags
163 notebook_flags = ['no-browser', 'no-mathjax', 'read-only']
165 notebook_flags = ['no-browser', 'no-mathjax', 'read-only', 'script']
164
166
165 aliases = dict(ipkernel_aliases)
167 aliases = dict(ipkernel_aliases)
166
168
@@ -23,15 +23,22 b' import glob'
23
23
24 from tornado import web
24 from tornado import web
25
25
26 from IPython.config.application import boolean_flag
26 from IPython.config.configurable import LoggingConfigurable
27 from IPython.config.configurable import LoggingConfigurable
27 from IPython.nbformat import current
28 from IPython.nbformat import current
28 from IPython.utils.traitlets import Unicode, List, Dict, Bool
29 from IPython.utils.traitlets import Unicode, List, Dict, Bool
29
30
30
31 #-----------------------------------------------------------------------------
31 #-----------------------------------------------------------------------------
32 # Code
32 # Aliases and Flags
33 #-----------------------------------------------------------------------------
33 #-----------------------------------------------------------------------------
34
34
35 manager_flags =boolean_flag('script', 'NotebookManager.save_script',
36 'Auto-save a .py script everytime the .ipynb notebook is saved',
37 'Do not auto-save .py scripts for every notebook')
38
39 #-----------------------------------------------------------------------------
40 # Classes
41 #-----------------------------------------------------------------------------
35
42
36 class NotebookManager(LoggingConfigurable):
43 class NotebookManager(LoggingConfigurable):
37
44
@@ -40,10 +47,12 b' class NotebookManager(LoggingConfigurable):'
40 """)
47 """)
41
48
42 save_script = Bool(False, config=True,
49 save_script = Bool(False, config=True,
43 help="""Also save notebooks as a Python script.
50 help="""Automaticall create a Python script when saving the notebook.
44
51
45 For easier use of import/%loadpy across notebooks, a <notebook-name>.py
52 For easier use of import, %run and %loadpy across notebooks, a
46 script will be created next to any <notebook-name>.ipynb on each save.
53 <notebook-name>.py script will be created next to any
54 <notebook-name>.ipynb on each save. This can also be set with the
55 short `--script` flag.
47 """
56 """
48 )
57 )
49
58
General Comments 0
You need to be logged in to leave comments. Login now