diff --git a/IPython/config/default/ipython_config.py b/IPython/config/default/ipython_config.py index c60f159..100962a 100644 --- a/IPython/config/default/ipython_config.py +++ b/IPython/config/default/ipython_config.py @@ -2,106 +2,137 @@ # Global options #----------------------------------------------------------------------------- -Global.classic = False -Global.nosep = False +# Global.display_banner = True + +# Global.classic = False + +# Global.nosep = True + +# Set this to determine the detail of what is logged at startup. +# The default is 30 and possible values are 0,10,20,30,40,50. +# Global.log_level = 30 + +# This should be a list of importable Python modules that have an +# load_in_ipython(ip) method. This method gets called when the extension +# is loaded. You can put your extensions anywhere they can be imported +# but we add the extensions subdir of the ipython directory to sys.path +# during extension loading, so you can put them there as well. +# Global.extensions = [ +# 'myextension' +# ] + +# These lines are run in IPython in the user's namespace after extensions +# are loaded. They can contain full IPython syntax with magics etc. +# Global.exec_lines = [ +# 'import numpy', +# 'a = 10; b = 20', +# '1/0' +# ] + +# These files are run in IPython in the user's namespace. Files with a .py +# extension need to be pure Python. Files with a .ipy extension can have +# custom IPython syntax (like magics, etc.). +# These files need to be in the cwd, the ipythondir or be absolute paths. +# Global.exec_files = [ +# 'mycode.py', +# 'fancy.ipy' +# ] #----------------------------------------------------------------------------- # InteractiveShell options #----------------------------------------------------------------------------- -InteractiveShell.autocall = 1 +# InteractiveShell.autocall = 1 -InteractiveShell.autoedit_syntax = False +# InteractiveShell.autoedit_syntax = False -InteractiveShell.autoindent = True +# InteractiveShell.autoindent = True -InteractiveShell.automagic = False +# InteractiveShell.automagic = False -InteractiveShell.banner1 = 'This if for overriding the default IPython banner' +# InteractiveShell.banner1 = 'This if for overriding the default IPython banner' -InteractiveShell.banner2 = "This is for extra banner text" +# InteractiveShell.banner2 = "This is for extra banner text" -InteractiveShell.cache_size = 1000 +# InteractiveShell.cache_size = 1000 -InteractiveShell.colors = 'LightBG' +# InteractiveShell.colors = 'LightBG' -InteractiveShell.color_info = True +# InteractiveShell.color_info = True -InteractiveShell.confirm_exit = True +# InteractiveShell.confirm_exit = True -InteractiveShell.deep_reload = False +# InteractiveShell.deep_reload = False -InteractiveShell.display_banner = True +# InteractiveShell.editor = 'nano' -InteractiveShell.editor = 'nano' +# InteractiveShell.logstart = True -InteractiveShell.logstart = True +# InteractiveShell.logfile = 'ipython_log.py' -InteractiveShell.logfile = 'ipython_log.py' +# InteractiveShell.logplay = 'mylog.py' -InteractiveShell.logplay = 'mylog.py' +# InteractiveShell.object_info_string_level = 0 -InteractiveShell.object_info_string_level = 0 +# InteractiveShell.pager = 'less' -InteractiveShell.pager = 'less' +# InteractiveShell.pdb = False -InteractiveShell.pdb = False +# InteractiveShell.pprint = True -InteractiveShell.pprint = True +# InteractiveShell.prompt_in1 = 'In [\#]: ' +# InteractiveShell.prompt_in2 = ' .\D.: ' +# InteractiveShell.prompt_out = 'Out[\#]: ' +# InteractiveShell.prompts_pad_left = True -InteractiveShell.prompt_in1 = 'In [\#]: ' -InteractiveShell.prompt_in2 = ' .\D.: ' -InteractiveShell.prompt_out = 'Out[\#]: ' -InteractiveShell.prompts_pad_left = True - -InteractiveShell.quiet = False +# InteractiveShell.quiet = False # Readline -InteractiveShell.readline_use = False +# InteractiveShell.readline_use = True -InteractiveShell.readline_parse_and_bind = [ - 'tab: complete', - '"\C-l": possible-completions', - 'set show-all-if-ambiguous on', - '"\C-o": tab-insert', - '"\M-i": " "', - '"\M-o": "\d\d\d\d"', - '"\M-I": "\d\d\d\d"', - '"\C-r": reverse-search-history', - '"\C-s": forward-search-history', - '"\C-p": history-search-backward', - '"\C-n": history-search-forward', - '"\e[A": history-search-backward', - '"\e[B": history-search-forward', - '"\C-k": kill-line', - '"\C-u": unix-line-discard', -] -InteractiveShell.readline_remove_delims = '-/~' -InteractiveShell.readline_merge_completions = True -InteractiveShell.readline_omit_names = 0 +# InteractiveShell.readline_parse_and_bind = [ +# 'tab: complete', +# '"\C-l": possible-completions', +# 'set show-all-if-ambiguous on', +# '"\C-o": tab-insert', +# '"\M-i": " "', +# '"\M-o": "\d\d\d\d"', +# '"\M-I": "\d\d\d\d"', +# '"\C-r": reverse-search-history', +# '"\C-s": forward-search-history', +# '"\C-p": history-search-backward', +# '"\C-n": history-search-forward', +# '"\e[A": history-search-backward', +# '"\e[B": history-search-forward', +# '"\C-k": kill-line', +# '"\C-u": unix-line-discard', +# ] +# InteractiveShell.readline_remove_delims = '-/~' +# InteractiveShell.readline_merge_completions = True +# InteractiveShell.readline_omit_names = 0 -InteractiveShell.screen_length = 0 +# InteractiveShell.screen_length = 0 -InteractiveShell.separate_in = '\n' -InteractiveShell.separate_out = '' -InteractiveShell.separate_out2 = '' +# InteractiveShell.separate_in = '\n' +# InteractiveShell.separate_out = '' +# InteractiveShell.separate_out2 = '' -InteractiveShell.system_header = "IPython system call: " +# InteractiveShell.system_header = "IPython system call: " -InteractiveShell.system_verbose = True +# InteractiveShell.system_verbose = True -InteractiveShell.term_title = False +# InteractiveShell.term_title = False -InteractiveShell.wildcards_case_sensitive = True +# InteractiveShell.wildcards_case_sensitive = True -InteractiveShell.xmode = 'Context' +# InteractiveShell.xmode = 'Context' #----------------------------------------------------------------------------- # PrefilterManager options #----------------------------------------------------------------------------- -PrefilterManager.multi_line_specials = True +# PrefilterManager.multi_line_specials = True #----------------------------------------------------------------------------- # AliasManager options @@ -110,6 +141,6 @@ PrefilterManager.multi_line_specials = True # Do this to enable all defaults # AliasManager.default_aliases = [] -AliasManger.user_aliases = [ - ('foo', 'echo Hi') -] \ No newline at end of file +# AliasManger.user_aliases = [ + # ('foo', 'echo Hi') +# ] \ No newline at end of file diff --git a/IPython/config/loader.py b/IPython/config/loader.py index 433c076..ea3a5b7 100644 --- a/IPython/config/loader.py +++ b/IPython/config/loader.py @@ -234,12 +234,29 @@ class PyFileConfigLoader(FileConfigLoader): self.full_filename = filefind(self.filename, self.path) def _read_file_as_dict(self): - execfile(self.full_filename, self.config) + """Load the config file into self.config, with recursive loading.""" + # This closure is made available in the namespace that is used + # to exec the config file. This allows users to call + # load_subconfig('myconfig.py') to load config files recursively. + # It needs to be a closure because it has references to self.path + # and self.config. The sub-config is loaded with the same path + # as the parent, but it uses an empty config which is then merged + # with the parents. + def load_subconfig(fname): + loader = PyFileConfigLoader(fname, self.path) + sub_config = loader.load_config() + self.config._merge(sub_config) + + self.config.load_subconfig = load_subconfig + try: + execfile(self.full_filename, self.config) + finally: + del self.config.load_subconfig + del self.config['__builtins__'] def _convert_to_config(self): if self.data is None: ConfigLoaderError('self.data does not exist') - del self.config['__builtins__'] class CommandLineConfigLoader(ConfigLoader): diff --git a/IPython/config/profile/ipython_config_math.py b/IPython/config/profile/ipython_config_math.py index 2238227..0dad772 100644 --- a/IPython/config/profile/ipython_config_math.py +++ b/IPython/config/profile/ipython_config_math.py @@ -1,8 +1,17 @@ -from ipython_config import * +# This can be used at any point in a config file to load a sub config +# and merge it into the current one. +load_subconfig('ipython_config.py') -Global.exec_lines.extend([ - 'import cmath', - 'from math import *', - 'print "*** math functions available globally, cmath as a module"' -]) +lines = """ +import cmath +from math import * +""" + +# You have to make sure that attributes that are containers already +# exist before using them. Simple assigning a new list will override +# all previous values. +if hasattr(Global, 'exec_lines'): + Global.exec_lines.append(lines) +else: + Global.exec_lines = [lines] diff --git a/IPython/config/profile/ipython_config_numeric.py b/IPython/config/profile/ipython_config_numeric.py index 28031fa..5660e5a 100644 --- a/IPython/config/profile/ipython_config_numeric.py +++ b/IPython/config/profile/ipython_config_numeric.py @@ -1,8 +1,18 @@ -from ipython_config import * +# This can be used at any point in a config file to load a sub config +# and merge it into the current one. +load_subconfig('ipython_config.py') -Global.exec_lines.extend([ - 'import numpy', - 'import scipy', - 'import numpy as np', - 'import scipy as sp', -]) \ No newline at end of file +lines = """ +import numpy +import scipy +import numpy as np +import scipy as sp +""" + +# You have to make sure that attributes that are containers already +# exist before using them. Simple assigning a new list will override +# all previous values. +if hasattr(Global, 'exec_lines'): + Global.exec_lines.append(lines) +else: + Global.exec_lines = [lines] \ No newline at end of file diff --git a/IPython/config/profile/ipython_config_pylab.py b/IPython/config/profile/ipython_config_pylab.py index edf6c5d..5a39a82 100644 --- a/IPython/config/profile/ipython_config_pylab.py +++ b/IPython/config/profile/ipython_config_pylab.py @@ -1,8 +1,20 @@ -from ipython_config_numeric import * +# This can be used at any point in a config file to load a sub config +# and merge it into the current one. +load_subconfig('ipython_config.py') -Global.exec_lines.extend([ - 'import matplotlib', - 'from matplotlib import pyplot as plt', - 'from matplotlib.pyplot import *' -]) +lines = """ +import matplotlib +%gui -a wx +matplotlib.use('wxagg') +matplotlib.interactive(True) +from matplotlib import pyplot as plt +from matplotlib.pyplot import * +""" +# You have to make sure that attributes that are containers already +# exist before using them. Simple assigning a new list will override +# all previous values. +if hasattr(Global, 'exec_lines'): + Global.exec_lines.append(lines) +else: + Global.exec_lines = [lines] \ No newline at end of file diff --git a/IPython/config/profile/ipython_config_pysh.py b/IPython/config/profile/ipython_config_pysh.py index 3fe3f95..986fec3 100644 --- a/IPython/config/profile/ipython_config_pysh.py +++ b/IPython/config/profile/ipython_config_pysh.py @@ -1,6 +1,8 @@ -from ipython_config import * +# This can be used at any point in a config file to load a sub config +# and merge it into the current one. +load_subconfig('ipython_config.py') -InteractiveShell.prompt_in2 = '\C_LightGreen\u@\h\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> ' +InteractiveShell.prompt_in1 = '\C_LightGreen\u@\h\C_LightBlue[\C_LightCyan\Y1\C_LightBlue]\C_Green|\#> ' InteractiveShell.prompt_in2 = '\C_Green|\C_LightGreen\D\C_Green> ' InteractiveShell.prompt_out = '<\#> ' @@ -10,4 +12,16 @@ InteractiveShell.separate_in = '' InteractiveShell.separate_out = '' InteractiveShell.separate_out2 = '' -PrefilterManager.multi_line_specials = True \ No newline at end of file +PrefilterManager.multi_line_specials = True + +lines = """ +%rehashx +""" + +# You have to make sure that attributes that are containers already +# exist before using them. Simple assigning a new list will override +# all previous values. +if hasattr(Global, 'exec_lines'): + Global.exec_lines.append(lines) +else: + Global.exec_lines = [lines] \ No newline at end of file diff --git a/IPython/config/profile/ipython_config_sympy.py b/IPython/config/profile/ipython_config_sympy.py index 2bf5bef..f9dedb8 100644 --- a/IPython/config/profile/ipython_config_sympy.py +++ b/IPython/config/profile/ipython_config_sympy.py @@ -1,9 +1,19 @@ -from ipython_config import * +# This can be used at any point in a config file to load a sub config +# and merge it into the current one. +load_subconfig('ipython_config.py') -Global.exec_lines.extend([ - "from __future__ import division" - "from sympy import *" - "x, y, z = symbols('xyz')" - "k, m, n = symbols('kmn', integer=True)" - "f, g, h = map(Function, 'fgh')" -]) +lines = """ +from __future__ import division +from sympy import * +x, y, z = symbols('xyz') +k, m, n = symbols('kmn', integer=True) +f, g, h = map(Function, 'fgh') +""" + +# You have to make sure that attributes that are containers already +# exist before using them. Simple assigning a new list will override +# all previous values. +if hasattr(Global, 'exec_lines'): + Global.exec_lines.append(lines) +else: + Global.exec_lines = [lines]