Define flags in application that's going to use them.

This commit is contained in:
Fernando Perez 2011-12-17 18:12:41 -08:00
parent b3d5732690
commit 7c7a48e2ce
2 changed files with 7 additions and 13 deletions

View File

@ -50,9 +50,9 @@ from .handlers import (LoginHandler, LogoutHandler,
MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler, MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler,
ShellHandler, NotebookRootHandler, NotebookHandler, RSTHandler ShellHandler, NotebookRootHandler, NotebookHandler, RSTHandler
) )
from .notebookmanager import NotebookManager, manager_flags 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.application import BaseIPythonApplication
from IPython.core.profiledir import ProfileDir from IPython.core.profiledir import ProfileDir
from IPython.lib.kernel import swallow_argv from IPython.lib.kernel import swallow_argv
@ -157,12 +157,15 @@ flags['read-only'] = (
""" """
) )
flags.update(manager_flags) # 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 # the flags that are specific to the frontend
# these must be scrubbed before being passed to the kernel, # these must be scrubbed before being passed to the kernel,
# or it will raise an error on unrecognized flags # or it will raise an error on unrecognized flags
notebook_flags = ['no-browser', 'no-mathjax', 'read-only', 'script'] notebook_flags = ['no-browser', 'no-mathjax', 'read-only', 'script', 'no-script']
aliases = dict(ipkernel_aliases) aliases = dict(ipkernel_aliases)

View File

@ -23,19 +23,10 @@ import glob
from tornado import web from tornado import web
from IPython.config.application import boolean_flag
from IPython.config.configurable import LoggingConfigurable from IPython.config.configurable import LoggingConfigurable
from IPython.nbformat import current from IPython.nbformat import current
from IPython.utils.traitlets import Unicode, List, Dict, Bool from IPython.utils.traitlets import Unicode, List, Dict, Bool
#-----------------------------------------------------------------------------
# Aliases and Flags
#-----------------------------------------------------------------------------
manager_flags =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')
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Classes # Classes
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------