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)
| 318 | self.log.debug("IPYTHONDIR set to: %s", new) |
| 319 | |
| 320 | def load_config_file(self, suppress_errors=IPYTHON_SUPPRESS_CONFIG_ERRORS): |
| 321 | """Load the config file. |
| 322 | |
| 323 | By default, errors in loading config are handled, and a warning |
| 324 | printed on screen. For testing, the suppress_errors option is set |
| 325 | to False, so errors will make tests fail. |
| 326 | |
| 327 | `suppress_errors` default value is to be `None` in which case the |
| 328 | behavior default to the one of `traitlets.Application`. |
| 329 | |
| 330 | The default value can be set : |
| 331 | - to `False` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '0', or 'false' (case insensitive). |
| 332 | - to `True` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '1' or 'true' (case insensitive). |
| 333 | - to `None` by setting 'IPYTHON_SUPPRESS_CONFIG_ERRORS' environment variable to '' (empty string) or leaving it unset. |
| 334 | |
| 335 | Any other value are invalid, and will make IPython exit with a non-zero return code. |
| 336 | """ |
| 337 | |
| 338 | |
| 339 | self.log.debug("Searching path %s for config files", self.config_file_paths) |
| 340 | base_config = 'ipython_config.py' |
| 341 | self.log.debug("Attempting to load config file: %s" % |
| 342 | base_config) |
| 343 | try: |
| 344 | if suppress_errors is not None: |
| 345 | old_value = Application.raise_config_file_errors |
| 346 | Application.raise_config_file_errors = not suppress_errors |
| 347 | Application.load_config_file( |
| 348 | self, |
| 349 | base_config, |
| 350 | path=self.config_file_paths |
| 351 | ) |
| 352 | except ConfigFileNotFound: |
| 353 | # ignore errors loading parent |
| 354 | self.log.debug("Config file %s not found", base_config) |
| 355 | pass |
| 356 | if suppress_errors is not None: |
| 357 | Application.raise_config_file_errors = old_value |
| 358 | |
| 359 | for config_file_name in self.config_files: |
| 360 | if not config_file_name or config_file_name == base_config: |
| 361 | continue |
| 362 | self.log.debug("Attempting to load config file: %s" % |
| 363 | self.config_file_name) |
| 364 | try: |
| 365 | Application.load_config_file( |
| 366 | self, |
| 367 | config_file_name, |
| 368 | path=self.config_file_paths |
| 369 | ) |
| 370 | except ConfigFileNotFound: |
| 371 | # Only warn if the default config file was NOT being used. |
| 372 | if config_file_name in self.config_file_specified: |
| 373 | msg = self.log.warning |
| 374 | else: |
| 375 | msg = self.log.debug |
| 376 | msg("Config file not found, skipping: %s", config_file_name) |
| 377 | except Exception: |