Show More
@@ -39,7 +39,7 b' from IPython.config.loader import ConfigFileNotFound' | |||||
39 | from IPython.core import release, crashhandler |
|
39 | from IPython.core import release, crashhandler | |
40 | from IPython.core.profiledir import ProfileDir, ProfileDirError |
|
40 | from IPython.core.profiledir import ProfileDir, ProfileDirError | |
41 | 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 | |
42 | from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict |
|
42 | from IPython.utils.traitlets import List, Unicode, Type, Bool, Dict, Set | |
43 |
|
43 | |||
44 | #----------------------------------------------------------------------------- |
|
44 | #----------------------------------------------------------------------------- | |
45 | # Classes and functions |
|
45 | # Classes and functions | |
@@ -56,6 +56,7 b' base_aliases = {' | |||||
56 | 'profile' : 'BaseIPythonApplication.profile', |
|
56 | 'profile' : 'BaseIPythonApplication.profile', | |
57 | 'ipython-dir' : 'BaseIPythonApplication.ipython_dir', |
|
57 | 'ipython-dir' : 'BaseIPythonApplication.ipython_dir', | |
58 | 'log-level' : 'Application.log_level', |
|
58 | 'log-level' : 'Application.log_level', | |
|
59 | 'config' : 'BaseIPythonApplication.extra_config_file', | |||
59 | } |
|
60 | } | |
60 |
|
61 | |||
61 | base_flags = dict( |
|
62 | base_flags = dict( | |
@@ -84,14 +85,14 b' class BaseIPythonApplication(Application):' | |||||
84 |
|
85 | |||
85 | # Track whether the config_file has changed, |
|
86 | # Track whether the config_file has changed, | |
86 | # because some logic happens only if we aren't using the default. |
|
87 | # because some logic happens only if we aren't using the default. | |
87 |
config_file_specified = |
|
88 | config_file_specified = Set() | |
88 |
|
89 | |||
89 | config_file_name = Unicode(u'ipython_config.py') |
|
90 | config_file_name = Unicode(u'ipython_config.py') | |
90 | def _config_file_name_default(self): |
|
91 | def _config_file_name_default(self): | |
91 | return self.name.replace('-','_') + u'_config.py' |
|
92 | return self.name.replace('-','_') + u'_config.py' | |
92 | def _config_file_name_changed(self, name, old, new): |
|
93 | def _config_file_name_changed(self, name, old, new): | |
93 | if new != old: |
|
94 | if new != old: | |
94 |
self.config_file_specified |
|
95 | self.config_file_specified.add(new) | |
95 |
|
96 | |||
96 | # The directory that contains IPython's builtin profiles. |
|
97 | # The directory that contains IPython's builtin profiles. | |
97 | builtin_profile_dir = Unicode( |
|
98 | builtin_profile_dir = Unicode( | |
@@ -102,6 +103,19 b' class BaseIPythonApplication(Application):' | |||||
102 | def _config_file_paths_default(self): |
|
103 | def _config_file_paths_default(self): | |
103 | return [os.getcwdu()] |
|
104 | return [os.getcwdu()] | |
104 |
|
105 | |||
|
106 | extra_config_file = Unicode(config=True, | |||
|
107 | help="""Path to an extra config file to load. | |||
|
108 | ||||
|
109 | If specified, load this config file in addition to any other IPython config. | |||
|
110 | """) | |||
|
111 | def _extra_config_file_changed(self, name, old, new): | |||
|
112 | try: | |||
|
113 | self.config_files.remove(old) | |||
|
114 | except ValueError: | |||
|
115 | pass | |||
|
116 | self.config_file_specified.add(new) | |||
|
117 | self.config_files.append(new) | |||
|
118 | ||||
105 | profile = Unicode(u'default', config=True, |
|
119 | profile = Unicode(u'default', config=True, | |
106 | help="""The IPython profile to use.""" |
|
120 | help="""The IPython profile to use.""" | |
107 | ) |
|
121 | ) | |
@@ -216,24 +230,25 b' class BaseIPythonApplication(Application):' | |||||
216 | # ignore errors loading parent |
|
230 | # ignore errors loading parent | |
217 | self.log.debug("Config file %s not found", base_config) |
|
231 | self.log.debug("Config file %s not found", base_config) | |
218 | pass |
|
232 | pass | |
219 | if self.config_file_name == base_config: |
|
233 | ||
220 | # don't load secondary config |
|
234 | for config_file_name in self.config_files: | |
221 | return |
|
235 | if not config_file_name or config_file_name == base_config: | |
|
236 | continue | |||
222 | self.log.debug("Attempting to load config file: %s" % |
|
237 | self.log.debug("Attempting to load config file: %s" % | |
223 | self.config_file_name) |
|
238 | self.config_file_name) | |
224 | try: |
|
239 | try: | |
225 | Application.load_config_file( |
|
240 | Application.load_config_file( | |
226 | self, |
|
241 | self, | |
227 |
|
|
242 | config_file_name, | |
228 | path=self.config_file_paths |
|
243 | path=self.config_file_paths | |
229 | ) |
|
244 | ) | |
230 | except ConfigFileNotFound: |
|
245 | except ConfigFileNotFound: | |
231 | # Only warn if the default config file was NOT being used. |
|
246 | # Only warn if the default config file was NOT being used. | |
232 | if self.config_file_specified: |
|
247 | if config_file_name in self.config_file_specified: | |
233 | msg = self.log.warn |
|
248 | msg = self.log.warn | |
234 | else: |
|
249 | else: | |
235 | msg = self.log.debug |
|
250 | msg = self.log.debug | |
236 |
msg("Config file not found, skipping: %s", |
|
251 | msg("Config file not found, skipping: %s", config_file_name) | |
237 | except: |
|
252 | except: | |
238 | # For testing purposes. |
|
253 | # For testing purposes. | |
239 | if not suppress_errors: |
|
254 | if not suppress_errors: |
General Comments 0
You need to be logged in to leave comments.
Login now