From f9c612b8d6802d5a28dd56f2503a07e28b57b80d Mon Sep 17 00:00:00 2001 From: Shane Chin Date: Sun, 17 Apr 2016 16:45:51 -0700 Subject: [PATCH] Make ptipython respect more config changes Currently ptipython loads extension modules, but does not execute lines from the config file. --- ptpython/ipython.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ptpython/ipython.py b/ptpython/ipython.py index dc7b95e8..ae929f99 100644 --- a/ptpython/ipython.py +++ b/ptpython/ipython.py @@ -225,6 +225,24 @@ def initialize_extensions(shell, extensions): "Error in loading extension: %s" % ext + "\nCheck your config files in %s" % ipy_utils.path.get_ipython_dir()) shell.showtraceback() + +def run_exec_lines(shell, exec_lines): + """ + Partial copy of run_exec_lines code from IPython.core.shellapp . + """ + try: + iter(exec_lines) + except TypeError: + pass + else: + try: + for line in exec_lines: + try: + shell.run_cell(line, store_history=False) + except: + shell.showtraceback() + except: + shell.showtraceback() def embed(**kwargs): @@ -240,4 +258,5 @@ def embed(**kwargs): kwargs['config'] = config shell = InteractiveShellEmbed.instance(**kwargs) initialize_extensions(shell, config['InteractiveShellApp']['extensions']) + run_exec_lines(shell, config['InteractiveShellApp']['exec_lines']) shell(header=header, stack_depth=2, compile_flags=compile_flags)