Show More
@@ -39,7 +39,7 b' from IPython.config.loader import ConfigFileNotFound' | |||
|
39 | 39 | from IPython.core import release, crashhandler |
|
40 | 40 | from IPython.core.profiledir import ProfileDir, ProfileDirError |
|
41 | 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 | 45 | # Classes and functions |
@@ -56,6 +56,7 b' base_aliases = {' | |||
|
56 | 56 | 'profile' : 'BaseIPythonApplication.profile', |
|
57 | 57 | 'ipython-dir' : 'BaseIPythonApplication.ipython_dir', |
|
58 | 58 | 'log-level' : 'Application.log_level', |
|
59 | 'config' : 'BaseIPythonApplication.extra_config_file', | |
|
59 | 60 | } |
|
60 | 61 | |
|
61 | 62 | base_flags = dict( |
@@ -84,14 +85,14 b' class BaseIPythonApplication(Application):' | |||
|
84 | 85 | |
|
85 | 86 | # Track whether the config_file has changed, |
|
86 | 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 | 90 | config_file_name = Unicode(u'ipython_config.py') |
|
90 | 91 | def _config_file_name_default(self): |
|
91 | 92 | return self.name.replace('-','_') + u'_config.py' |
|
92 | 93 | def _config_file_name_changed(self, name, old, new): |
|
93 | 94 | if new != old: |
|
94 |
self.config_file_specified |
|
|
95 | self.config_file_specified.add(new) | |
|
95 | 96 | |
|
96 | 97 | # The directory that contains IPython's builtin profiles. |
|
97 | 98 | builtin_profile_dir = Unicode( |
@@ -102,6 +103,19 b' class BaseIPythonApplication(Application):' | |||
|
102 | 103 | def _config_file_paths_default(self): |
|
103 | 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 | 119 | profile = Unicode(u'default', config=True, |
|
106 | 120 | help="""The IPython profile to use.""" |
|
107 | 121 | ) |
@@ -216,24 +230,25 b' class BaseIPythonApplication(Application):' | |||
|
216 | 230 | # ignore errors loading parent |
|
217 | 231 | self.log.debug("Config file %s not found", base_config) |
|
218 | 232 | pass |
|
219 | if self.config_file_name == base_config: | |
|
220 | # don't load secondary config | |
|
221 | return | |
|
233 | ||
|
234 | for config_file_name in self.config_files: | |
|
235 | if not config_file_name or config_file_name == base_config: | |
|
236 | continue | |
|
222 | 237 | self.log.debug("Attempting to load config file: %s" % |
|
223 | 238 | self.config_file_name) |
|
224 | 239 | try: |
|
225 | 240 | Application.load_config_file( |
|
226 | 241 | self, |
|
227 |
|
|
|
242 | config_file_name, | |
|
228 | 243 | path=self.config_file_paths |
|
229 | 244 | ) |
|
230 | 245 | except ConfigFileNotFound: |
|
231 | 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 | 248 | msg = self.log.warn |
|
234 | 249 | else: |
|
235 | 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 | 252 | except: |
|
238 | 253 | # For testing purposes. |
|
239 | 254 | if not suppress_errors: |
General Comments 0
You need to be logged in to leave comments.
Login now