# HG changeset patch
# User J. H. Palmieri <palmieri@math.washington.edu>
# Date 1361903310 28800
# Node ID 8d5b47f3219290706989a2749735e47c5b98c8d5
# Parent be4962cdd100d0521c00f2469aa014e2a124ca5c
Merge user's IPython configuration with Sage's.
diff --git a/sage/misc/interpreter.py b/sage/misc/interpreter.py
a
|
b
|
|
649 | 649 | app, contact_name, contact_email, bug_tracker, show_crash_traceback=False) |
650 | 650 | self.crash_report_fname = 'Sage_crash_report.txt' |
651 | 651 | |
652 | | DEFAULT_SAGE_CONFIG = Config(PromptManager = Config(in_template = 'sage: ', |
653 | | in2_template = '....: ', |
654 | | justify = False, |
655 | | out_template = ''), |
656 | | TerminalIPythonApp = Config(display_banner = False, |
657 | | verbose_crash = True), |
658 | | TerminalInteractiveShell = Config(ast_node_interactivity = 'all', |
659 | | colors = 'NoColor', |
660 | | confirm_exit = False, |
661 | | separate_in = ''), |
662 | | # The extension is *always* loaded for SageTerminalApp |
663 | | # See the code for SageTerminalApp.init_shell |
664 | | #InteractiveShellApp = Config(extensions=['sage.misc.sage_extension']), |
| 652 | DEFAULT_SAGE_CONFIG = Config( |
| 653 | PromptManager = Config( |
| 654 | in_template = 'sage: ', |
| 655 | in2_template = '....: ', |
| 656 | justify = False, |
| 657 | out_template = ''), |
| 658 | TerminalIPythonApp = Config( |
| 659 | display_banner = False, |
| 660 | verbose_crash = True), |
| 661 | TerminalInteractiveShell = Config( |
| 662 | ast_node_interactivity = 'all', |
| 663 | colors = 'LightBG', |
| 664 | confirm_exit = False, |
| 665 | separate_in = ''), |
| 666 | # The extension is *always* loaded for SageTerminalApp |
| 667 | # See the code for SageTerminalApp.init_shell |
| 668 | #InteractiveShellApp = Config(extensions=['sage.misc.sage_extension']), |
665 | 669 | ) |
666 | 670 | |
667 | 671 | class SageTerminalApp(TerminalIPythonApp): |
… |
… |
|
670 | 674 | test_shell = False |
671 | 675 | |
672 | 676 | def __init__(self, **kwargs): |
673 | | # Overwrite the default Sage configuration with the user's. |
674 | | new_config = Config() |
675 | | new_config._merge(DEFAULT_SAGE_CONFIG) |
676 | | new_config._merge(kwargs.get('config', Config())) |
677 | | kwargs['config']=new_config |
| 677 | self.command_line_config = kwargs.get('config', Config()) |
678 | 678 | super(SageTerminalApp, self).__init__(**kwargs) |
679 | 679 | |
680 | 680 | |
| 681 | def load_config_file(self, *args, **kwds): |
| 682 | from IPython.frontend.terminal.ipapp import default_config_file_name |
| 683 | from IPython.config.loader import PyFileConfigLoader, ConfigFileNotFound |
| 684 | from IPython.core.profiledir import ProfileDir |
| 685 | from IPython.utils.path import get_ipython_dir |
| 686 | |
| 687 | conf = Config() |
| 688 | conf._merge(DEFAULT_SAGE_CONFIG) |
| 689 | conf._merge(self.command_line_config) |
| 690 | |
| 691 | # Get user config. |
| 692 | sage_profile_dir = ProfileDir.find_profile_dir_by_name( |
| 693 | get_ipython_dir(), 'sage').location |
| 694 | try: |
| 695 | cl = PyFileConfigLoader(default_config_file_name, sage_profile_dir) |
| 696 | conf._merge(cl.load_config()) |
| 697 | except ConfigFileNotFound: |
| 698 | pass |
| 699 | self.update_config(conf) |
| 700 | |
| 701 | |
681 | 702 | def init_shell(self): |
682 | 703 | r""" |
683 | 704 | Initialize the :class:`SageInteractiveShell` instance. |