From 12620da9920b4834e7ce09d3c54d35b97d1190d2 2016-05-17 18:06:36 From: Matthias Bussonnier Date: 2016-05-17 18:06:36 Subject: [PATCH] Update a few observer and .tag(config=True) to match new traitlets API. --- diff --git a/IPython/core/profileapp.py b/IPython/core/profileapp.py index fecdc0d..37f47ee 100644 --- a/IPython/core/profileapp.py +++ b/IPython/core/profileapp.py @@ -32,7 +32,7 @@ from IPython.core.profiledir import ProfileDir from IPython.utils.importstring import import_item from IPython.paths import get_ipython_dir, get_ipython_package_dir from IPython.utils import py3compat -from traitlets import Unicode, Bool, Dict +from traitlets import Unicode, Bool, Dict, observe #----------------------------------------------------------------------------- # Constants @@ -149,14 +149,14 @@ class ProfileList(Application): ) )) - ipython_dir = Unicode(get_ipython_dir(), config=True, + ipython_dir = Unicode(get_ipython_dir(), help=""" The name of the IPython directory. This directory is used for logging configuration (through profiles), history storage, etc. The default is usually $HOME/.ipython. This options can also be specified through the environment variable IPYTHONDIR. """ - ) + ).tag(config=True) def _print_profiles(self, profiles): @@ -211,15 +211,18 @@ class ProfileCreate(BaseIPythonApplication): name = u'ipython-profile' description = create_help examples = _create_examples - auto_create = Bool(True, config=False) + auto_create = Bool(True) def _log_format_default(self): return "[%(name)s] %(message)s" def _copy_config_files_default(self): return True - parallel = Bool(False, config=True, - help="whether to include parallel computing config files") + parallel = Bool(False, + help="whether to include parallel computing config files" + ).tag(config=True) + + @observe('parallel') def _parallel_changed(self, name, old, new): parallel_files = [ 'ipcontroller_config.py', 'ipengine_config.py', diff --git a/IPython/core/prompts.py b/IPython/core/prompts.py index 70f2e30..0f42557 100644 --- a/IPython/core/prompts.py +++ b/IPython/core/prompts.py @@ -285,6 +285,7 @@ class PromptManager(Configurable): # The number of characters in each prompt which don't contribute to width invisible_chars = Dict() + @default('invisible_chars') def _invisible_chars_default(self): return {'in': 0, 'in2': 0, 'out': 0, 'rewrite':0} @@ -321,7 +322,9 @@ class PromptManager(Configurable): invis_chars = _invisible_characters(self._render(name, color=True)) self.invisible_chars[name] = invis_chars - def _update_prompt_trait(self, traitname, new_template): + def _update_prompt_trait(self, changes): + traitname = changes['name'] + new_template = changes['new'] name = traitname[:-9] # Cut off '_template' self.update_prompt(name, new_template)