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

Method _run_startup_files

IPython/core/shellapp.py:356–384  ·  view source on GitHub ↗

Run files from profile startup directory

(self)

Source from the content-addressed store, hash-verified

354 sys.argv = save_argv
355
356 def _run_startup_files(self):
357 """Run files from profile startup directory"""
358 startup_dirs = [self.profile_dir.startup_dir] + [
359 os.path.join(p, 'startup') for p in chain(ENV_CONFIG_DIRS, SYSTEM_CONFIG_DIRS)
360 ]
361 startup_files = []
362
363 if self.exec_PYTHONSTARTUP and os.environ.get('PYTHONSTARTUP', False) and \
364 not (self.file_to_run or self.code_to_run or self.module_to_run):
365 python_startup = os.environ['PYTHONSTARTUP']
366 self.log.debug("Running PYTHONSTARTUP file %s...", python_startup)
367 try:
368 self._exec_file(python_startup)
369 except:
370 self.log.warning("Unknown error in handling PYTHONSTARTUP file %s:", python_startup)
371 self.shell.showtraceback()
372 for startup_dir in startup_dirs[::-1]:
373 startup_files += glob.glob(os.path.join(startup_dir, '*.py'))
374 startup_files += glob.glob(os.path.join(startup_dir, '*.ipy'))
375 if not startup_files:
376 return
377
378 self.log.debug("Running startup files from %s...", startup_dir)
379 try:
380 for fname in sorted(startup_files):
381 self._exec_file(fname)
382 except:
383 self.log.warning("Unknown error in handling startup files:")
384 self.shell.showtraceback()
385
386 def _run_exec_files(self):
387 """Run files from IPythonApp.exec_files"""

Callers 1

init_codeMethod · 0.95

Calls 3

_exec_fileMethod · 0.95
debugMethod · 0.80
showtracebackMethod · 0.80

Tested by

no test coverage detected