##// END OF EJS Templates
Merge pull request #2689 from Carreau/configurable-docfixes...
Thomas Kluyver -
r8886:8a314195 merge
parent child Browse files
Show More
@@ -51,7 +51,7 b' class MultipleInstanceError(ConfigurableError):'
51
51
52 class Configurable(HasTraits):
52 class Configurable(HasTraits):
53
53
54 config = Instance(Config,(),{})
54 config = Instance(Config, (), {})
55 created = None
55 created = None
56
56
57 def __init__(self, **kwargs):
57 def __init__(self, **kwargs):
@@ -72,7 +72,7 b' class Configurable(HasTraits):'
72
72
73 class MyConfigurable(Configurable):
73 class MyConfigurable(Configurable):
74 def __init__(self, config=None):
74 def __init__(self, config=None):
75 super(MyConfigurable, self).__init__(config)
75 super(MyConfigurable, self).__init__(config=config)
76 # Then any other code you need to finish initialization.
76 # Then any other code you need to finish initialization.
77
77
78 This ensures that instances will be configured properly.
78 This ensures that instances will be configured properly.
@@ -165,7 +165,7 b' class Configurable(HasTraits):'
165 final_help = []
165 final_help = []
166 final_help.append(u'%s options' % cls.__name__)
166 final_help.append(u'%s options' % cls.__name__)
167 final_help.append(len(final_help[0])*u'-')
167 final_help.append(len(final_help[0])*u'-')
168 for k,v in sorted(cls.class_traits(config=True).iteritems()):
168 for k, v in sorted(cls.class_traits(config=True).iteritems()):
169 help = cls.class_get_trait_help(v, inst)
169 help = cls.class_get_trait_help(v, inst)
170 final_help.append(help)
170 final_help.append(help)
171 return '\n'.join(final_help)
171 return '\n'.join(final_help)
@@ -218,7 +218,7 b' class Configurable(HasTraits):'
218
218
219 # section header
219 # section header
220 breaker = '#' + '-'*78
220 breaker = '#' + '-'*78
221 s = "# %s configuration"%cls.__name__
221 s = "# %s configuration" % cls.__name__
222 lines = [breaker, s, breaker, '']
222 lines = [breaker, s, breaker, '']
223 # get the description trait
223 # get the description trait
224 desc = cls.class_traits().get('description')
224 desc = cls.class_traits().get('description')
@@ -245,7 +245,7 b' class Configurable(HasTraits):'
245 lines.append(c('%s will inherit config from: %s'%(cls.__name__, pstr)))
245 lines.append(c('%s will inherit config from: %s'%(cls.__name__, pstr)))
246 lines.append('')
246 lines.append('')
247
247
248 for name,trait in cls.class_traits(config=True).iteritems():
248 for name, trait in cls.class_traits(config=True).iteritems():
249 help = trait.get_metadata('help') or ''
249 help = trait.get_metadata('help') or ''
250 lines.append(c(help))
250 lines.append(c(help))
251 lines.append('# c.%s.%s = %r'%(cls.__name__, name, trait.get_default_value()))
251 lines.append('# c.%s.%s = %r'%(cls.__name__, name, trait.get_default_value()))
@@ -35,13 +35,11 b' import shutil'
35 import sys
35 import sys
36
36
37 from IPython.config.application import Application, catch_config_error
37 from IPython.config.application import Application, catch_config_error
38 from IPython.config.configurable import Configurable
38 from IPython.config.loader import ConfigFileNotFound
39 from IPython.config.loader import Config, ConfigFileNotFound
40 from IPython.core import release, crashhandler
39 from IPython.core import release, crashhandler
41 from IPython.core.profiledir import ProfileDir, ProfileDirError
40 from IPython.core.profiledir import ProfileDir, ProfileDirError
42 from IPython.utils.path import get_ipython_dir, get_ipython_package_dir
41 from IPython.utils.path import get_ipython_dir, get_ipython_package_dir
43 from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict
42 from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict
44 from IPython.utils import py3compat
45
43
46 #-----------------------------------------------------------------------------
44 #-----------------------------------------------------------------------------
47 # Classes and functions
45 # Classes and functions
@@ -245,7 +243,7 b' class BaseIPythonApplication(Application):'
245 p = ProfileDir.find_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
243 p = ProfileDir.find_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
246 except ProfileDirError:
244 except ProfileDirError:
247 # not found, maybe create it (always create default profile)
245 # not found, maybe create it (always create default profile)
248 if self.auto_create or self.profile=='default':
246 if self.auto_create or self.profile == 'default':
249 try:
247 try:
250 p = ProfileDir.create_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
248 p = ProfileDir.create_profile_dir_by_name(self.ipython_dir, self.profile, self.config)
251 except ProfileDirError:
249 except ProfileDirError:
General Comments 0
You need to be logged in to leave comments. Login now