From 302975348b0dbd4f0ddbb699df76ee05ffbefaaf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 17 Jul 2021 09:40:58 +0200 Subject: Merging upstream version 3.0.19. Signed-off-by: Daniel Baumann --- ptpython/ipython.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'ptpython/ipython.py') diff --git a/ptpython/ipython.py b/ptpython/ipython.py index 2e8d119..9163334 100644 --- a/ptpython/ipython.py +++ b/ptpython/ipython.py @@ -282,4 +282,21 @@ def embed(**kwargs): kwargs["config"] = config shell = InteractiveShellEmbed.instance(**kwargs) initialize_extensions(shell, config["InteractiveShellApp"]["extensions"]) + run_startup_scripts(shell) shell(header=header, stack_depth=2, compile_flags=compile_flags) + + +def run_startup_scripts(shell): + """ + Contributed by linyuxu: + https://github.com/prompt-toolkit/ptpython/issues/126#issue-161242480 + """ + import glob + import os + + startup_dir = shell.profile_dir.startup_dir + startup_files = [] + startup_files += glob.glob(os.path.join(startup_dir, "*.py")) + startup_files += glob.glob(os.path.join(startup_dir, "*.ipy")) + for file in startup_files: + shell.run_cell(open(file).read()) -- cgit v1.2.3