MCPcopy Create free account
hub / github.com/ipython/ipython / load_config_file

Method load_config_file

IPython/core/application.py:289–351  ·  view source on GitHub ↗

Load the config file. By default, errors in loading config are handled, and a warning printed on screen. For testing, the suppress_errors option is set to False, so errors will make tests fail. `suppress_errors` default value is to be `None` in which case the

(self, suppress_errors=IPYTHON_SUPPRESS_CONFIG_ERRORS)

Source from the content-addressed store, hash-verified

287 self.log.debug("IPYTHONDIR set to: %s" % new)
288
289 def load_config_file(self, suppress_errors=IPYTHON_SUPPRESS_CONFIG_ERRORS):
290 """Load the config file.
291
292 By default, errors in loading config are handled, and a warning
293 printed on screen. For testing, the suppress_errors option is set
294 to False, so errors will make tests fail.
295
296 `suppress_errors` default value is to be `None` in which case the
297 behavior default to the one of `traitlets.Application`.
298
299 The default value can be set :
300 - to `False` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '0', or 'false' (case insensitive).
301 - to `True` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '1' or 'true' (case insensitive).
302 - to `None` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '' (empty string) or leaving it unset.
303
304 Any other value are invalid, and will make IPython exit with a non-zero return code.
305 """
306
307
308 self.log.debug("Searching path %s for config files", self.config_file_paths)
309 base_config = 'ipython_config.py'
310 self.log.debug("Attempting to load config file: %s" %
311 base_config)
312 try:
313 if suppress_errors is not None:
314 old_value = Application.raise_config_file_errors
315 Application.raise_config_file_errors = not suppress_errors;
316 Application.load_config_file(
317 self,
318 base_config,
319 path=self.config_file_paths
320 )
321 except ConfigFileNotFound:
322 # ignore errors loading parent
323 self.log.debug("Config file %s not found", base_config)
324 pass
325 if suppress_errors is not None:
326 Application.raise_config_file_errors = old_value
327
328 for config_file_name in self.config_files:
329 if not config_file_name or config_file_name == base_config:
330 continue
331 self.log.debug("Attempting to load config file: %s" %
332 self.config_file_name)
333 try:
334 Application.load_config_file(
335 self,
336 config_file_name,
337 path=self.config_file_paths
338 )
339 except ConfigFileNotFound:
340 # Only warn if the default config file was NOT being used.
341 if config_file_name in self.config_file_specified:
342 msg = self.log.warning
343 else:
344 msg = self.log.debug
345 msg("Config file not found, skipping: %s", config_file_name)
346 except Exception:

Callers 4

initializeMethod · 0.95
test_unicode_cwdFunction · 0.95
test_unicode_ipdirFunction · 0.95
load_default_configFunction · 0.80

Calls 1

debugMethod · 0.80

Tested by 2

test_unicode_cwdFunction · 0.76
test_unicode_ipdirFunction · 0.76