##// END OF EJS Templates
david cournapeau patch from ticket \#107 (import_some fix). doc changes
vivainio -
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,34 +1,36 b''
1 """ User configuration file for IPython
1 """ User configuration file for IPython
2
2
3 This is a more flexible and safe way to configure ipython than *rc files
3 This is a more flexible and safe way to configure ipython than *rc files
4 (ipythonrc, ipythonrc-pysh etc.)
4 (ipythonrc, ipythonrc-pysh etc.)
5
5
6 This file is always imported on ipython startup. You can import the
6 This file is always imported on ipython startup. You can import the
7 ipython extensions you need here (see IPython/Extensions directory).
7 ipython extensions you need here (see IPython/Extensions directory).
8
8
9 Feel free to edit this file to customize your ipython experience.
9 Feel free to edit this file to customize your ipython experience.
10
10
11 Note that as such this file does nothing, for backwards compatibility.
11 Note that as such this file does nothing, for backwards compatibility.
12 Consult e.g. file 'ipy_profile_sh.py' for an example of the things
12 Consult e.g. file 'ipy_profile_sh.py' for an example of the things
13 you can do here.
13 you can do here.
14
14
15 See http://ipython.scipy.org/moin/IpythonExtensionApi for detailed
16 description on what you could do here.
15 """
17 """
16
18
17 # Most of your config files and extensions will probably start with this import
19 # Most of your config files and extensions will probably start with this import
18
20
19 import IPython.ipapi
21 import IPython.ipapi
20 ip = IPython.ipapi.get()
22 ip = IPython.ipapi.get()
21
23
22 # You probably want to uncomment this if you did %upgrade -nolegacy
24 # You probably want to uncomment this if you did %upgrade -nolegacy
23 # import ipy_defaults
25 # import ipy_defaults
24
26
25 def main():
27 def main():
26 # Handy tab-completers for %cd, %run, import etc.
28 # Handy tab-completers for %cd, %run, import etc.
27 # Try commenting this out if you have completion problems/slowness
29 # Try commenting this out if you have completion problems/slowness
28 import ipy_stock_completers
30 import ipy_stock_completers
29
31
30 o = ip.options
32 o = ip.options
31 # An example on how to set options
33 # An example on how to set options
32 #o.autocall = 1
34 #o.autocall = 1
33
35
34 main()
36 main()
@@ -1,616 +1,623 b''
1 # -*- Mode: Shell-Script -*- Not really, but shows comments correctly
1 # -*- Mode: Shell-Script -*- Not really, but shows comments correctly
2 # $Id: ipythonrc 1879 2006-11-04 00:34:34Z fptest $
2 # $Id: ipythonrc 1979 2006-12-12 18:50:20Z vivainio $
3
3
4 #***************************************************************************
4 #***************************************************************************
5 #
5 #
6 # Configuration file for IPython -- ipythonrc format
6 # Configuration file for IPython -- ipythonrc format
7 #
7 #
8 # ===========================================================
9 # Deprecation note: you should look into modifying ipy_user_conf.py (located
10 # in ~/.ipython or ~/_ipython, depending on your platform) instead, it's a
11 # more flexible and robust (and better supported!) configuration
12 # method.
13 # ===========================================================
14 #
8 # The format of this file is simply one of 'key value' lines.
15 # The format of this file is simply one of 'key value' lines.
9 # Lines containing only whitespace at the beginning and then a # are ignored
16 # Lines containing only whitespace at the beginning and then a # are ignored
10 # as comments. But comments can NOT be put on lines with data.
17 # as comments. But comments can NOT be put on lines with data.
11
18
12 # The meaning and use of each key are explained below.
19 # The meaning and use of each key are explained below.
13
20
14 #---------------------------------------------------------------------------
21 #---------------------------------------------------------------------------
15 # Section: included files
22 # Section: included files
16
23
17 # Put one or more *config* files (with the syntax of this file) you want to
24 # Put one or more *config* files (with the syntax of this file) you want to
18 # include. For keys with a unique value the outermost file has precedence. For
25 # include. For keys with a unique value the outermost file has precedence. For
19 # keys with multiple values, they all get assembled into a list which then
26 # keys with multiple values, they all get assembled into a list which then
20 # gets loaded by IPython.
27 # gets loaded by IPython.
21
28
22 # In this file, all lists of things should simply be space-separated.
29 # In this file, all lists of things should simply be space-separated.
23
30
24 # This allows you to build hierarchies of files which recursively load
31 # This allows you to build hierarchies of files which recursively load
25 # lower-level services. If this is your main ~/.ipython/ipythonrc file, you
32 # lower-level services. If this is your main ~/.ipython/ipythonrc file, you
26 # should only keep here basic things you always want available. Then you can
33 # should only keep here basic things you always want available. Then you can
27 # include it in every other special-purpose config file you create.
34 # include it in every other special-purpose config file you create.
28 include
35 include
29
36
30 #---------------------------------------------------------------------------
37 #---------------------------------------------------------------------------
31 # Section: startup setup
38 # Section: startup setup
32
39
33 # These are mostly things which parallel a command line option of the same
40 # These are mostly things which parallel a command line option of the same
34 # name.
41 # name.
35
42
36 # Keys in this section should only appear once. If any key from this section
43 # Keys in this section should only appear once. If any key from this section
37 # is encountered more than once, the last value remains, all earlier ones get
44 # is encountered more than once, the last value remains, all earlier ones get
38 # discarded.
45 # discarded.
39
46
40
47
41 # Automatic calling of callable objects. If set to 1 or 2, callable objects
48 # Automatic calling of callable objects. If set to 1 or 2, callable objects
42 # are automatically called when invoked at the command line, even if you don't
49 # are automatically called when invoked at the command line, even if you don't
43 # type parentheses. IPython adds the parentheses for you. For example:
50 # type parentheses. IPython adds the parentheses for you. For example:
44
51
45 #In [1]: str 45
52 #In [1]: str 45
46 #------> str(45)
53 #------> str(45)
47 #Out[1]: '45'
54 #Out[1]: '45'
48
55
49 # IPython reprints your line with '---->' indicating that it added
56 # IPython reprints your line with '---->' indicating that it added
50 # parentheses. While this option is very convenient for interactive use, it
57 # parentheses. While this option is very convenient for interactive use, it
51 # may occasionally cause problems with objects which have side-effects if
58 # may occasionally cause problems with objects which have side-effects if
52 # called unexpectedly.
59 # called unexpectedly.
53
60
54 # The valid values for autocall are:
61 # The valid values for autocall are:
55
62
56 # autocall 0 -> disabled (you can toggle it at runtime with the %autocall magic)
63 # autocall 0 -> disabled (you can toggle it at runtime with the %autocall magic)
57
64
58 # autocall 1 -> active, but do not apply if there are no arguments on the line.
65 # autocall 1 -> active, but do not apply if there are no arguments on the line.
59
66
60 # In this mode, you get:
67 # In this mode, you get:
61
68
62 #In [1]: callable
69 #In [1]: callable
63 #Out[1]: <built-in function callable>
70 #Out[1]: <built-in function callable>
64
71
65 #In [2]: callable 'hello'
72 #In [2]: callable 'hello'
66 #------> callable('hello')
73 #------> callable('hello')
67 #Out[2]: False
74 #Out[2]: False
68
75
69 # 2 -> Active always. Even if no arguments are present, the callable object
76 # 2 -> Active always. Even if no arguments are present, the callable object
70 # is called:
77 # is called:
71
78
72 #In [4]: callable
79 #In [4]: callable
73 #------> callable()
80 #------> callable()
74
81
75 # Note that even with autocall off, you can still use '/' at the start of a
82 # Note that even with autocall off, you can still use '/' at the start of a
76 # line to treat the first argument on the command line as a function and add
83 # line to treat the first argument on the command line as a function and add
77 # parentheses to it:
84 # parentheses to it:
78
85
79 #In [8]: /str 43
86 #In [8]: /str 43
80 #------> str(43)
87 #------> str(43)
81 #Out[8]: '43'
88 #Out[8]: '43'
82
89
83 autocall 1
90 autocall 1
84
91
85 # Auto-edit syntax errors. When you use the %edit magic in ipython to edit
92 # Auto-edit syntax errors. When you use the %edit magic in ipython to edit
86 # source code (see the 'editor' variable below), it is possible that you save
93 # source code (see the 'editor' variable below), it is possible that you save
87 # a file with syntax errors in it. If this variable is true, IPython will ask
94 # a file with syntax errors in it. If this variable is true, IPython will ask
88 # you whether to re-open the editor immediately to correct such an error.
95 # you whether to re-open the editor immediately to correct such an error.
89
96
90 autoedit_syntax 0
97 autoedit_syntax 0
91
98
92 # Auto-indent. IPython can recognize lines ending in ':' and indent the next
99 # Auto-indent. IPython can recognize lines ending in ':' and indent the next
93 # line, while also un-indenting automatically after 'raise' or 'return'.
100 # line, while also un-indenting automatically after 'raise' or 'return'.
94
101
95 # This feature uses the readline library, so it will honor your ~/.inputrc
102 # This feature uses the readline library, so it will honor your ~/.inputrc
96 # configuration (or whatever file your INPUTRC variable points to). Adding
103 # configuration (or whatever file your INPUTRC variable points to). Adding
97 # the following lines to your .inputrc file can make indent/unindenting more
104 # the following lines to your .inputrc file can make indent/unindenting more
98 # convenient (M-i indents, M-u unindents):
105 # convenient (M-i indents, M-u unindents):
99
106
100 # $if Python
107 # $if Python
101 # "\M-i": " "
108 # "\M-i": " "
102 # "\M-u": "\d\d\d\d"
109 # "\M-u": "\d\d\d\d"
103 # $endif
110 # $endif
104
111
105 # The feature is potentially a bit dangerous, because it can cause problems
112 # The feature is potentially a bit dangerous, because it can cause problems
106 # with pasting of indented code (the pasted code gets re-indented on each
113 # with pasting of indented code (the pasted code gets re-indented on each
107 # line). But it's a huge time-saver when working interactively. The magic
114 # line). But it's a huge time-saver when working interactively. The magic
108 # function %autoindent allows you to toggle it on/off at runtime.
115 # function %autoindent allows you to toggle it on/off at runtime.
109
116
110 autoindent 1
117 autoindent 1
111
118
112 # Auto-magic. This gives you access to all the magic functions without having
119 # Auto-magic. This gives you access to all the magic functions without having
113 # to prepend them with an % sign. If you define a variable with the same name
120 # to prepend them with an % sign. If you define a variable with the same name
114 # as a magic function (say who=1), you will need to access the magic function
121 # as a magic function (say who=1), you will need to access the magic function
115 # with % (%who in this example). However, if later you delete your variable
122 # with % (%who in this example). However, if later you delete your variable
116 # (del who), you'll recover the automagic calling form.
123 # (del who), you'll recover the automagic calling form.
117
124
118 # Considering that many magic functions provide a lot of shell-like
125 # Considering that many magic functions provide a lot of shell-like
119 # functionality, automagic gives you something close to a full Python+system
126 # functionality, automagic gives you something close to a full Python+system
120 # shell environment (and you can extend it further if you want).
127 # shell environment (and you can extend it further if you want).
121
128
122 automagic 1
129 automagic 1
123
130
124 # Size of the output cache. After this many entries are stored, the cache will
131 # Size of the output cache. After this many entries are stored, the cache will
125 # get flushed. Depending on the size of your intermediate calculations, you
132 # get flushed. Depending on the size of your intermediate calculations, you
126 # may have memory problems if you make it too big, since keeping things in the
133 # may have memory problems if you make it too big, since keeping things in the
127 # cache prevents Python from reclaiming the memory for old results. Experiment
134 # cache prevents Python from reclaiming the memory for old results. Experiment
128 # with a value that works well for you.
135 # with a value that works well for you.
129
136
130 # If you choose cache_size 0 IPython will revert to python's regular >>>
137 # If you choose cache_size 0 IPython will revert to python's regular >>>
131 # unnumbered prompt. You will still have _, __ and ___ for your last three
138 # unnumbered prompt. You will still have _, __ and ___ for your last three
132 # results, but that will be it. No dynamic _1, _2, etc. will be created. If
139 # results, but that will be it. No dynamic _1, _2, etc. will be created. If
133 # you are running on a slow machine or with very limited memory, this may
140 # you are running on a slow machine or with very limited memory, this may
134 # help.
141 # help.
135
142
136 cache_size 1000
143 cache_size 1000
137
144
138 # Classic mode: Setting 'classic 1' you lose many of IPython niceties,
145 # Classic mode: Setting 'classic 1' you lose many of IPython niceties,
139 # but that's your choice! Classic 1 -> same as IPython -classic.
146 # but that's your choice! Classic 1 -> same as IPython -classic.
140 # Note that this is _not_ the normal python interpreter, it's simply
147 # Note that this is _not_ the normal python interpreter, it's simply
141 # IPython emulating most of the classic interpreter's behavior.
148 # IPython emulating most of the classic interpreter's behavior.
142 classic 0
149 classic 0
143
150
144 # colors - Coloring option for prompts and traceback printouts.
151 # colors - Coloring option for prompts and traceback printouts.
145
152
146 # Currently available schemes: NoColor, Linux, LightBG.
153 # Currently available schemes: NoColor, Linux, LightBG.
147
154
148 # This option allows coloring the prompts and traceback printouts. This
155 # This option allows coloring the prompts and traceback printouts. This
149 # requires a terminal which can properly handle color escape sequences. If you
156 # requires a terminal which can properly handle color escape sequences. If you
150 # are having problems with this, use the NoColor scheme (uses no color escapes
157 # are having problems with this, use the NoColor scheme (uses no color escapes
151 # at all).
158 # at all).
152
159
153 # The Linux option works well in linux console type environments: dark
160 # The Linux option works well in linux console type environments: dark
154 # background with light fonts.
161 # background with light fonts.
155
162
156 # LightBG is similar to Linux but swaps dark/light colors to be more readable
163 # LightBG is similar to Linux but swaps dark/light colors to be more readable
157 # in light background terminals.
164 # in light background terminals.
158
165
159 # keep uncommented only the one you want:
166 # keep uncommented only the one you want:
160 colors Linux
167 colors Linux
161 #colors LightBG
168 #colors LightBG
162 #colors NoColor
169 #colors NoColor
163
170
164 ########################
171 ########################
165 # Note to Windows users
172 # Note to Windows users
166 #
173 #
167 # Color and readline support is avaialble to Windows users via Gary Bishop's
174 # Color and readline support is avaialble to Windows users via Gary Bishop's
168 # readline library. You can find Gary's tools at
175 # readline library. You can find Gary's tools at
169 # http://sourceforge.net/projects/uncpythontools.
176 # http://sourceforge.net/projects/uncpythontools.
170 # Note that his readline module requires in turn the ctypes library, available
177 # Note that his readline module requires in turn the ctypes library, available
171 # at http://starship.python.net/crew/theller/ctypes.
178 # at http://starship.python.net/crew/theller/ctypes.
172 ########################
179 ########################
173
180
174 # color_info: IPython can display information about objects via a set of
181 # color_info: IPython can display information about objects via a set of
175 # functions, and optionally can use colors for this, syntax highlighting
182 # functions, and optionally can use colors for this, syntax highlighting
176 # source code and various other elements. This information is passed through a
183 # source code and various other elements. This information is passed through a
177 # pager (it defaults to 'less' if $PAGER is not set).
184 # pager (it defaults to 'less' if $PAGER is not set).
178
185
179 # If your pager has problems, try to setting it to properly handle escapes
186 # If your pager has problems, try to setting it to properly handle escapes
180 # (see the less manpage for detail), or disable this option. The magic
187 # (see the less manpage for detail), or disable this option. The magic
181 # function %color_info allows you to toggle this interactively for testing.
188 # function %color_info allows you to toggle this interactively for testing.
182
189
183 color_info 1
190 color_info 1
184
191
185 # confirm_exit: set to 1 if you want IPython to confirm when you try to exit
192 # confirm_exit: set to 1 if you want IPython to confirm when you try to exit
186 # with an EOF (Control-d in Unix, Control-Z/Enter in Windows). Note that using
193 # with an EOF (Control-d in Unix, Control-Z/Enter in Windows). Note that using
187 # the magic functions %Exit or %Quit you can force a direct exit, bypassing
194 # the magic functions %Exit or %Quit you can force a direct exit, bypassing
188 # any confirmation.
195 # any confirmation.
189
196
190 confirm_exit 1
197 confirm_exit 1
191
198
192 # Use deep_reload() as a substitute for reload() by default. deep_reload() is
199 # Use deep_reload() as a substitute for reload() by default. deep_reload() is
193 # still available as dreload() and appears as a builtin.
200 # still available as dreload() and appears as a builtin.
194
201
195 deep_reload 0
202 deep_reload 0
196
203
197 # Which editor to use with the %edit command. If you leave this at 0, IPython
204 # Which editor to use with the %edit command. If you leave this at 0, IPython
198 # will honor your EDITOR environment variable. Since this editor is invoked on
205 # will honor your EDITOR environment variable. Since this editor is invoked on
199 # the fly by ipython and is meant for editing small code snippets, you may
206 # the fly by ipython and is meant for editing small code snippets, you may
200 # want to use a small, lightweight editor here.
207 # want to use a small, lightweight editor here.
201
208
202 # For Emacs users, setting up your Emacs server properly as described in the
209 # For Emacs users, setting up your Emacs server properly as described in the
203 # manual is a good idea. An alternative is to use jed, a very light editor
210 # manual is a good idea. An alternative is to use jed, a very light editor
204 # with much of the feel of Emacs (though not as powerful for heavy-duty work).
211 # with much of the feel of Emacs (though not as powerful for heavy-duty work).
205
212
206 editor 0
213 editor 0
207
214
208 # log 1 -> same as ipython -log. This automatically logs to ./ipython.log
215 # log 1 -> same as ipython -log. This automatically logs to ./ipython.log
209 log 0
216 log 0
210
217
211 # Same as ipython -Logfile YourLogfileName.
218 # Same as ipython -Logfile YourLogfileName.
212 # Don't use with log 1 (use one or the other)
219 # Don't use with log 1 (use one or the other)
213 logfile ''
220 logfile ''
214
221
215 # banner 0 -> same as ipython -nobanner
222 # banner 0 -> same as ipython -nobanner
216 banner 1
223 banner 1
217
224
218 # messages 0 -> same as ipython -nomessages
225 # messages 0 -> same as ipython -nomessages
219 messages 1
226 messages 1
220
227
221 # Automatically call the pdb debugger after every uncaught exception. If you
228 # Automatically call the pdb debugger after every uncaught exception. If you
222 # are used to debugging using pdb, this puts you automatically inside of it
229 # are used to debugging using pdb, this puts you automatically inside of it
223 # after any call (either in IPython or in code called by it) which triggers an
230 # after any call (either in IPython or in code called by it) which triggers an
224 # exception which goes uncaught.
231 # exception which goes uncaught.
225 pdb 0
232 pdb 0
226
233
227 # Enable the pprint module for printing. pprint tends to give a more readable
234 # Enable the pprint module for printing. pprint tends to give a more readable
228 # display (than print) for complex nested data structures.
235 # display (than print) for complex nested data structures.
229 pprint 1
236 pprint 1
230
237
231 # Prompt strings
238 # Prompt strings
232
239
233 # Most bash-like escapes can be used to customize IPython's prompts, as well as
240 # Most bash-like escapes can be used to customize IPython's prompts, as well as
234 # a few additional ones which are IPython-specific. All valid prompt escapes
241 # a few additional ones which are IPython-specific. All valid prompt escapes
235 # are described in detail in the Customization section of the IPython HTML/PDF
242 # are described in detail in the Customization section of the IPython HTML/PDF
236 # manual.
243 # manual.
237
244
238 # Use \# to represent the current prompt number, and quote them to protect
245 # Use \# to represent the current prompt number, and quote them to protect
239 # spaces.
246 # spaces.
240 prompt_in1 'In [\#]: '
247 prompt_in1 'In [\#]: '
241
248
242 # \D is replaced by as many dots as there are digits in the
249 # \D is replaced by as many dots as there are digits in the
243 # current value of \#.
250 # current value of \#.
244 prompt_in2 ' .\D.: '
251 prompt_in2 ' .\D.: '
245
252
246 prompt_out 'Out[\#]: '
253 prompt_out 'Out[\#]: '
247
254
248 # Select whether to left-pad the output prompts to match the length of the
255 # Select whether to left-pad the output prompts to match the length of the
249 # input ones. This allows you for example to use a simple '>' as an output
256 # input ones. This allows you for example to use a simple '>' as an output
250 # prompt, and yet have the output line up with the input. If set to false,
257 # prompt, and yet have the output line up with the input. If set to false,
251 # the output prompts will be unpadded (flush left).
258 # the output prompts will be unpadded (flush left).
252 prompts_pad_left 1
259 prompts_pad_left 1
253
260
254 # quick 1 -> same as ipython -quick
261 # quick 1 -> same as ipython -quick
255 quick 0
262 quick 0
256
263
257 # Use the readline library (1) or not (0). Most users will want this on, but
264 # Use the readline library (1) or not (0). Most users will want this on, but
258 # if you experience strange problems with line management (mainly when using
265 # if you experience strange problems with line management (mainly when using
259 # IPython inside Emacs buffers) you may try disabling it. Not having it on
266 # IPython inside Emacs buffers) you may try disabling it. Not having it on
260 # prevents you from getting command history with the arrow keys, searching and
267 # prevents you from getting command history with the arrow keys, searching and
261 # name completion using TAB.
268 # name completion using TAB.
262
269
263 readline 1
270 readline 1
264
271
265 # Screen Length: number of lines of your screen. This is used to control
272 # Screen Length: number of lines of your screen. This is used to control
266 # printing of very long strings. Strings longer than this number of lines will
273 # printing of very long strings. Strings longer than this number of lines will
267 # be paged with the less command instead of directly printed.
274 # be paged with the less command instead of directly printed.
268
275
269 # The default value for this is 0, which means IPython will auto-detect your
276 # The default value for this is 0, which means IPython will auto-detect your
270 # screen size every time it needs to print. If for some reason this isn't
277 # screen size every time it needs to print. If for some reason this isn't
271 # working well (it needs curses support), specify it yourself. Otherwise don't
278 # working well (it needs curses support), specify it yourself. Otherwise don't
272 # change the default.
279 # change the default.
273
280
274 screen_length 0
281 screen_length 0
275
282
276 # Prompt separators for input and output.
283 # Prompt separators for input and output.
277 # Use \n for newline explicitly, without quotes.
284 # Use \n for newline explicitly, without quotes.
278 # Use 0 (like at the cmd line) to turn off a given separator.
285 # Use 0 (like at the cmd line) to turn off a given separator.
279
286
280 # The structure of prompt printing is:
287 # The structure of prompt printing is:
281 # (SeparateIn)Input....
288 # (SeparateIn)Input....
282 # (SeparateOut)Output...
289 # (SeparateOut)Output...
283 # (SeparateOut2), # that is, no newline is printed after Out2
290 # (SeparateOut2), # that is, no newline is printed after Out2
284 # By choosing these you can organize your output any way you want.
291 # By choosing these you can organize your output any way you want.
285
292
286 separate_in \n
293 separate_in \n
287 separate_out 0
294 separate_out 0
288 separate_out2 0
295 separate_out2 0
289
296
290 # 'nosep 1' is a shorthand for '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'.
297 # 'nosep 1' is a shorthand for '-SeparateIn 0 -SeparateOut 0 -SeparateOut2 0'.
291 # Simply removes all input/output separators, overriding the choices above.
298 # Simply removes all input/output separators, overriding the choices above.
292 nosep 0
299 nosep 0
293
300
294 # Wildcard searches - IPython has a system for searching names using
301 # Wildcard searches - IPython has a system for searching names using
295 # shell-like wildcards; type %psearch? for details. This variables sets
302 # shell-like wildcards; type %psearch? for details. This variables sets
296 # whether by default such searches should be case sensitive or not. You can
303 # whether by default such searches should be case sensitive or not. You can
297 # always override the default at the system command line or the IPython
304 # always override the default at the system command line or the IPython
298 # prompt.
305 # prompt.
299
306
300 wildcards_case_sensitive 1
307 wildcards_case_sensitive 1
301
308
302 # Object information: at what level of detail to display the string form of an
309 # Object information: at what level of detail to display the string form of an
303 # object. If set to 0, ipython will compute the string form of any object X,
310 # object. If set to 0, ipython will compute the string form of any object X,
304 # by calling str(X), when X? is typed. If set to 1, str(X) will only be
311 # by calling str(X), when X? is typed. If set to 1, str(X) will only be
305 # computed when X?? is given, and if set to 2 or higher, it will never be
312 # computed when X?? is given, and if set to 2 or higher, it will never be
306 # computed (there is no X??? level of detail). This is mostly of use to
313 # computed (there is no X??? level of detail). This is mostly of use to
307 # people who frequently manipulate objects whose string representation is
314 # people who frequently manipulate objects whose string representation is
308 # extremely expensive to compute.
315 # extremely expensive to compute.
309
316
310 object_info_string_level 0
317 object_info_string_level 0
311
318
312 # xmode - Exception reporting mode.
319 # xmode - Exception reporting mode.
313
320
314 # Valid modes: Plain, Context and Verbose.
321 # Valid modes: Plain, Context and Verbose.
315
322
316 # Plain: similar to python's normal traceback printing.
323 # Plain: similar to python's normal traceback printing.
317
324
318 # Context: prints 5 lines of context source code around each line in the
325 # Context: prints 5 lines of context source code around each line in the
319 # traceback.
326 # traceback.
320
327
321 # Verbose: similar to Context, but additionally prints the variables currently
328 # Verbose: similar to Context, but additionally prints the variables currently
322 # visible where the exception happened (shortening their strings if too
329 # visible where the exception happened (shortening their strings if too
323 # long). This can potentially be very slow, if you happen to have a huge data
330 # long). This can potentially be very slow, if you happen to have a huge data
324 # structure whose string representation is complex to compute. Your computer
331 # structure whose string representation is complex to compute. Your computer
325 # may appear to freeze for a while with cpu usage at 100%. If this occurs, you
332 # may appear to freeze for a while with cpu usage at 100%. If this occurs, you
326 # can cancel the traceback with Ctrl-C (maybe hitting it more than once).
333 # can cancel the traceback with Ctrl-C (maybe hitting it more than once).
327
334
328 #xmode Plain
335 #xmode Plain
329 xmode Context
336 xmode Context
330 #xmode Verbose
337 #xmode Verbose
331
338
332 # multi_line_specials: if true, allow magics, aliases and shell escapes (via
339 # multi_line_specials: if true, allow magics, aliases and shell escapes (via
333 # !cmd) to be used in multi-line input (like for loops). For example, if you
340 # !cmd) to be used in multi-line input (like for loops). For example, if you
334 # have this active, the following is valid in IPython:
341 # have this active, the following is valid in IPython:
335 #
342 #
336 #In [17]: for i in range(3):
343 #In [17]: for i in range(3):
337 # ....: mkdir $i
344 # ....: mkdir $i
338 # ....: !touch $i/hello
345 # ....: !touch $i/hello
339 # ....: ls -l $i
346 # ....: ls -l $i
340
347
341 multi_line_specials 1
348 multi_line_specials 1
342
349
343
350
344 # System calls: When IPython makes system calls (e.g. via special syntax like
351 # System calls: When IPython makes system calls (e.g. via special syntax like
345 # !cmd or !!cmd, or magics like %sc or %sx), it can print the command it is
352 # !cmd or !!cmd, or magics like %sc or %sx), it can print the command it is
346 # executing to standard output, prefixed by a header string.
353 # executing to standard output, prefixed by a header string.
347
354
348 system_header "IPython system call: "
355 system_header "IPython system call: "
349
356
350 system_verbose 1
357 system_verbose 1
351
358
352 # wxversion: request a specific wxPython version (used for -wthread)
359 # wxversion: request a specific wxPython version (used for -wthread)
353
360
354 # Set this to the value of wxPython you want to use, but note that this
361 # Set this to the value of wxPython you want to use, but note that this
355 # feature requires you to have the wxversion Python module to work. If you
362 # feature requires you to have the wxversion Python module to work. If you
356 # don't have the wxversion module (try 'import wxversion' at the prompt to
363 # don't have the wxversion module (try 'import wxversion' at the prompt to
357 # check) or simply want to leave the system to pick up the default, leave this
364 # check) or simply want to leave the system to pick up the default, leave this
358 # variable at 0.
365 # variable at 0.
359
366
360 wxversion 0
367 wxversion 0
361
368
362 #---------------------------------------------------------------------------
369 #---------------------------------------------------------------------------
363 # Section: Readline configuration (readline is not available for MS-Windows)
370 # Section: Readline configuration (readline is not available for MS-Windows)
364
371
365 # This is done via the following options:
372 # This is done via the following options:
366
373
367 # (i) readline_parse_and_bind: this option can appear as many times as you
374 # (i) readline_parse_and_bind: this option can appear as many times as you
368 # want, each time defining a string to be executed via a
375 # want, each time defining a string to be executed via a
369 # readline.parse_and_bind() command. The syntax for valid commands of this
376 # readline.parse_and_bind() command. The syntax for valid commands of this
370 # kind can be found by reading the documentation for the GNU readline library,
377 # kind can be found by reading the documentation for the GNU readline library,
371 # as these commands are of the kind which readline accepts in its
378 # as these commands are of the kind which readline accepts in its
372 # configuration file.
379 # configuration file.
373
380
374 # The TAB key can be used to complete names at the command line in one of two
381 # The TAB key can be used to complete names at the command line in one of two
375 # ways: 'complete' and 'menu-complete'. The difference is that 'complete' only
382 # ways: 'complete' and 'menu-complete'. The difference is that 'complete' only
376 # completes as much as possible while 'menu-complete' cycles through all
383 # completes as much as possible while 'menu-complete' cycles through all
377 # possible completions. Leave the one you prefer uncommented.
384 # possible completions. Leave the one you prefer uncommented.
378
385
379 readline_parse_and_bind tab: complete
386 readline_parse_and_bind tab: complete
380 #readline_parse_and_bind tab: menu-complete
387 #readline_parse_and_bind tab: menu-complete
381
388
382 # This binds Control-l to printing the list of all possible completions when
389 # This binds Control-l to printing the list of all possible completions when
383 # there is more than one (what 'complete' does when hitting TAB twice, or at
390 # there is more than one (what 'complete' does when hitting TAB twice, or at
384 # the first TAB if show-all-if-ambiguous is on)
391 # the first TAB if show-all-if-ambiguous is on)
385 readline_parse_and_bind "\C-l": possible-completions
392 readline_parse_and_bind "\C-l": possible-completions
386
393
387 # This forces readline to automatically print the above list when tab
394 # This forces readline to automatically print the above list when tab
388 # completion is set to 'complete'. You can still get this list manually by
395 # completion is set to 'complete'. You can still get this list manually by
389 # using the key bound to 'possible-completions' (Control-l by default) or by
396 # using the key bound to 'possible-completions' (Control-l by default) or by
390 # hitting TAB twice. Turning this on makes the printing happen at the first
397 # hitting TAB twice. Turning this on makes the printing happen at the first
391 # TAB.
398 # TAB.
392 readline_parse_and_bind set show-all-if-ambiguous on
399 readline_parse_and_bind set show-all-if-ambiguous on
393
400
394 # If you have TAB set to complete names, you can rebind any key (Control-o by
401 # If you have TAB set to complete names, you can rebind any key (Control-o by
395 # default) to insert a true TAB character.
402 # default) to insert a true TAB character.
396 readline_parse_and_bind "\C-o": tab-insert
403 readline_parse_and_bind "\C-o": tab-insert
397
404
398 # These commands allow you to indent/unindent easily, with the 4-space
405 # These commands allow you to indent/unindent easily, with the 4-space
399 # convention of the Python coding standards. Since IPython's internal
406 # convention of the Python coding standards. Since IPython's internal
400 # auto-indent system also uses 4 spaces, you should not change the number of
407 # auto-indent system also uses 4 spaces, you should not change the number of
401 # spaces in the code below.
408 # spaces in the code below.
402 readline_parse_and_bind "\M-i": " "
409 readline_parse_and_bind "\M-i": " "
403 readline_parse_and_bind "\M-o": "\d\d\d\d"
410 readline_parse_and_bind "\M-o": "\d\d\d\d"
404 readline_parse_and_bind "\M-I": "\d\d\d\d"
411 readline_parse_and_bind "\M-I": "\d\d\d\d"
405
412
406 # Bindings for incremental searches in the history. These searches use the
413 # Bindings for incremental searches in the history. These searches use the
407 # string typed so far on the command line and search anything in the previous
414 # string typed so far on the command line and search anything in the previous
408 # input history containing them.
415 # input history containing them.
409 readline_parse_and_bind "\C-r": reverse-search-history
416 readline_parse_and_bind "\C-r": reverse-search-history
410 readline_parse_and_bind "\C-s": forward-search-history
417 readline_parse_and_bind "\C-s": forward-search-history
411
418
412 # Bindings for completing the current line in the history of previous
419 # Bindings for completing the current line in the history of previous
413 # commands. This allows you to recall any previous command by typing its first
420 # commands. This allows you to recall any previous command by typing its first
414 # few letters and hitting Control-p, bypassing all intermediate commands which
421 # few letters and hitting Control-p, bypassing all intermediate commands which
415 # may be in the history (much faster than hitting up-arrow 50 times!)
422 # may be in the history (much faster than hitting up-arrow 50 times!)
416 readline_parse_and_bind "\C-p": history-search-backward
423 readline_parse_and_bind "\C-p": history-search-backward
417 readline_parse_and_bind "\C-n": history-search-forward
424 readline_parse_and_bind "\C-n": history-search-forward
418
425
419 # I also like to have the same functionality on the plain arrow keys. If you'd
426 # I also like to have the same functionality on the plain arrow keys. If you'd
420 # rather have the arrows use all the history (and not just match what you've
427 # rather have the arrows use all the history (and not just match what you've
421 # typed so far), comment out or delete the next two lines.
428 # typed so far), comment out or delete the next two lines.
422 readline_parse_and_bind "\e[A": history-search-backward
429 readline_parse_and_bind "\e[A": history-search-backward
423 readline_parse_and_bind "\e[B": history-search-forward
430 readline_parse_and_bind "\e[B": history-search-forward
424
431
425 # These are typically on by default under *nix, but not win32.
432 # These are typically on by default under *nix, but not win32.
426 readline_parse_and_bind "\C-k": kill-line
433 readline_parse_and_bind "\C-k": kill-line
427 readline_parse_and_bind "\C-u": unix-line-discard
434 readline_parse_and_bind "\C-u": unix-line-discard
428
435
429 # (ii) readline_remove_delims: a string of characters to be removed from the
436 # (ii) readline_remove_delims: a string of characters to be removed from the
430 # default word-delimiters list used by readline, so that completions may be
437 # default word-delimiters list used by readline, so that completions may be
431 # performed on strings which contain them.
438 # performed on strings which contain them.
432
439
433 readline_remove_delims -/~
440 readline_remove_delims -/~
434
441
435 # (iii) readline_merge_completions: whether to merge the result of all
442 # (iii) readline_merge_completions: whether to merge the result of all
436 # possible completions or not. If true, IPython will complete filenames,
443 # possible completions or not. If true, IPython will complete filenames,
437 # python names and aliases and return all possible completions. If you set it
444 # python names and aliases and return all possible completions. If you set it
438 # to false, each completer is used at a time, and only if it doesn't return
445 # to false, each completer is used at a time, and only if it doesn't return
439 # any completions is the next one used.
446 # any completions is the next one used.
440
447
441 # The default order is: [python_matches, file_matches, alias_matches]
448 # The default order is: [python_matches, file_matches, alias_matches]
442
449
443 readline_merge_completions 1
450 readline_merge_completions 1
444
451
445 # (iv) readline_omit__names: normally hitting <tab> after a '.' in a name
452 # (iv) readline_omit__names: normally hitting <tab> after a '.' in a name
446 # will complete all attributes of an object, including all the special methods
453 # will complete all attributes of an object, including all the special methods
447 # whose names start with single or double underscores (like __getitem__ or
454 # whose names start with single or double underscores (like __getitem__ or
448 # __class__).
455 # __class__).
449
456
450 # This variable allows you to control this completion behavior:
457 # This variable allows you to control this completion behavior:
451
458
452 # readline_omit__names 1 -> completion will omit showing any names starting
459 # readline_omit__names 1 -> completion will omit showing any names starting
453 # with two __, but it will still show names starting with one _.
460 # with two __, but it will still show names starting with one _.
454
461
455 # readline_omit__names 2 -> completion will omit all names beginning with one
462 # readline_omit__names 2 -> completion will omit all names beginning with one
456 # _ (which obviously means filtering out the double __ ones).
463 # _ (which obviously means filtering out the double __ ones).
457
464
458 # Even when this option is set, you can still see those names by explicitly
465 # Even when this option is set, you can still see those names by explicitly
459 # typing a _ after the period and hitting <tab>: 'name._<tab>' will always
466 # typing a _ after the period and hitting <tab>: 'name._<tab>' will always
460 # complete attribute names starting with '_'.
467 # complete attribute names starting with '_'.
461
468
462 # This option is off by default so that new users see all attributes of any
469 # This option is off by default so that new users see all attributes of any
463 # objects they are dealing with.
470 # objects they are dealing with.
464
471
465 readline_omit__names 0
472 readline_omit__names 0
466
473
467 #---------------------------------------------------------------------------
474 #---------------------------------------------------------------------------
468 # Section: modules to be loaded with 'import ...'
475 # Section: modules to be loaded with 'import ...'
469
476
470 # List, separated by spaces, the names of the modules you want to import
477 # List, separated by spaces, the names of the modules you want to import
471
478
472 # Example:
479 # Example:
473 # import_mod sys os
480 # import_mod sys os
474 # will produce internally the statements
481 # will produce internally the statements
475 # import sys
482 # import sys
476 # import os
483 # import os
477
484
478 # Each import is executed in its own try/except block, so if one module
485 # Each import is executed in its own try/except block, so if one module
479 # fails to load the others will still be ok.
486 # fails to load the others will still be ok.
480
487
481 import_mod
488 import_mod
482
489
483 #---------------------------------------------------------------------------
490 #---------------------------------------------------------------------------
484 # Section: modules to import some functions from: 'from ... import ...'
491 # Section: modules to import some functions from: 'from ... import ...'
485
492
486 # List, one per line, the modules for which you want only to import some
493 # List, one per line, the modules for which you want only to import some
487 # functions. Give the module name first and then the name of functions to be
494 # functions. Give the module name first and then the name of functions to be
488 # imported from that module.
495 # imported from that module.
489
496
490 # Example:
497 # Example:
491
498
492 # import_some IPython.genutils timing timings
499 # import_some IPython.genutils timing timings
493 # will produce internally the statement
500 # will produce internally the statement
494 # from IPython.genutils import timing, timings
501 # from IPython.genutils import timing, timings
495
502
496 # timing() and timings() are two IPython utilities for timing the execution of
503 # timing() and timings() are two IPython utilities for timing the execution of
497 # your own functions, which you may find useful. Just commment out the above
504 # your own functions, which you may find useful. Just commment out the above
498 # line if you want to test them.
505 # line if you want to test them.
499
506
500 # If you have more than one modules_some line, each gets its own try/except
507 # If you have more than one modules_some line, each gets its own try/except
501 # block (like modules, see above).
508 # block (like modules, see above).
502
509
503 import_some
510 import_some
504
511
505 #---------------------------------------------------------------------------
512 #---------------------------------------------------------------------------
506 # Section: modules to import all from : 'from ... import *'
513 # Section: modules to import all from : 'from ... import *'
507
514
508 # List (same syntax as import_mod above) those modules for which you want to
515 # List (same syntax as import_mod above) those modules for which you want to
509 # import all functions. Remember, this is a potentially dangerous thing to do,
516 # import all functions. Remember, this is a potentially dangerous thing to do,
510 # since it is very easy to overwrite names of things you need. Use with
517 # since it is very easy to overwrite names of things you need. Use with
511 # caution.
518 # caution.
512
519
513 # Example:
520 # Example:
514 # import_all sys os
521 # import_all sys os
515 # will produce internally the statements
522 # will produce internally the statements
516 # from sys import *
523 # from sys import *
517 # from os import *
524 # from os import *
518
525
519 # As before, each will be called in a separate try/except block.
526 # As before, each will be called in a separate try/except block.
520
527
521 import_all
528 import_all
522
529
523 #---------------------------------------------------------------------------
530 #---------------------------------------------------------------------------
524 # Section: Python code to execute.
531 # Section: Python code to execute.
525
532
526 # Put here code to be explicitly executed (keep it simple!)
533 # Put here code to be explicitly executed (keep it simple!)
527 # Put one line of python code per line. All whitespace is removed (this is a
534 # Put one line of python code per line. All whitespace is removed (this is a
528 # feature, not a bug), so don't get fancy building loops here.
535 # feature, not a bug), so don't get fancy building loops here.
529 # This is just for quick convenient creation of things you want available.
536 # This is just for quick convenient creation of things you want available.
530
537
531 # Example:
538 # Example:
532 # execute x = 1
539 # execute x = 1
533 # execute print 'hello world'; y = z = 'a'
540 # execute print 'hello world'; y = z = 'a'
534 # will produce internally
541 # will produce internally
535 # x = 1
542 # x = 1
536 # print 'hello world'; y = z = 'a'
543 # print 'hello world'; y = z = 'a'
537 # and each *line* (not each statement, we don't do python syntax parsing) is
544 # and each *line* (not each statement, we don't do python syntax parsing) is
538 # executed in its own try/except block.
545 # executed in its own try/except block.
539
546
540 execute
547 execute
541
548
542 # Note for the adventurous: you can use this to define your own names for the
549 # Note for the adventurous: you can use this to define your own names for the
543 # magic functions, by playing some namespace tricks:
550 # magic functions, by playing some namespace tricks:
544
551
545 # execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
552 # execute __IPYTHON__.magic_pf = __IPYTHON__.magic_profile
546
553
547 # defines %pf as a new name for %profile.
554 # defines %pf as a new name for %profile.
548
555
549 #---------------------------------------------------------------------------
556 #---------------------------------------------------------------------------
550 # Section: Pyhton files to load and execute.
557 # Section: Pyhton files to load and execute.
551
558
552 # Put here the full names of files you want executed with execfile(file). If
559 # Put here the full names of files you want executed with execfile(file). If
553 # you want complicated initialization, just write whatever you want in a
560 # you want complicated initialization, just write whatever you want in a
554 # regular python file and load it from here.
561 # regular python file and load it from here.
555
562
556 # Filenames defined here (which *must* include the extension) are searched for
563 # Filenames defined here (which *must* include the extension) are searched for
557 # through all of sys.path. Since IPython adds your .ipython directory to
564 # through all of sys.path. Since IPython adds your .ipython directory to
558 # sys.path, they can also be placed in your .ipython dir and will be
565 # sys.path, they can also be placed in your .ipython dir and will be
559 # found. Otherwise (if you want to execute things not in .ipyton nor in
566 # found. Otherwise (if you want to execute things not in .ipyton nor in
560 # sys.path) give a full path (you can use ~, it gets expanded)
567 # sys.path) give a full path (you can use ~, it gets expanded)
561
568
562 # Example:
569 # Example:
563 # execfile file1.py ~/file2.py
570 # execfile file1.py ~/file2.py
564 # will generate
571 # will generate
565 # execfile('file1.py')
572 # execfile('file1.py')
566 # execfile('_path_to_your_home/file2.py')
573 # execfile('_path_to_your_home/file2.py')
567
574
568 # As before, each file gets its own try/except block.
575 # As before, each file gets its own try/except block.
569
576
570 execfile
577 execfile
571
578
572 # If you are feeling adventurous, you can even add functionality to IPython
579 # If you are feeling adventurous, you can even add functionality to IPython
573 # through here. IPython works through a global variable called __ip which
580 # through here. IPython works through a global variable called __ip which
574 # exists at the time when these files are read. If you know what you are doing
581 # exists at the time when these files are read. If you know what you are doing
575 # (read the source) you can add functions to __ip in files loaded here.
582 # (read the source) you can add functions to __ip in files loaded here.
576
583
577 # The file example-magic.py contains a simple but correct example. Try it:
584 # The file example-magic.py contains a simple but correct example. Try it:
578
585
579 # execfile example-magic.py
586 # execfile example-magic.py
580
587
581 # Look at the examples in IPython/iplib.py for more details on how these magic
588 # Look at the examples in IPython/iplib.py for more details on how these magic
582 # functions need to process their arguments.
589 # functions need to process their arguments.
583
590
584 #---------------------------------------------------------------------------
591 #---------------------------------------------------------------------------
585 # Section: aliases for system shell commands
592 # Section: aliases for system shell commands
586
593
587 # Here you can define your own names for system commands. The syntax is
594 # Here you can define your own names for system commands. The syntax is
588 # similar to that of the builtin %alias function:
595 # similar to that of the builtin %alias function:
589
596
590 # alias alias_name command_string
597 # alias alias_name command_string
591
598
592 # The resulting aliases are auto-generated magic functions (hence usable as
599 # The resulting aliases are auto-generated magic functions (hence usable as
593 # %alias_name)
600 # %alias_name)
594
601
595 # For example:
602 # For example:
596
603
597 # alias myls ls -la
604 # alias myls ls -la
598
605
599 # will define 'myls' as an alias for executing the system command 'ls -la'.
606 # will define 'myls' as an alias for executing the system command 'ls -la'.
600 # This allows you to customize IPython's environment to have the same aliases
607 # This allows you to customize IPython's environment to have the same aliases
601 # you are accustomed to from your own shell.
608 # you are accustomed to from your own shell.
602
609
603 # You can also define aliases with parameters using %s specifiers (one per
610 # You can also define aliases with parameters using %s specifiers (one per
604 # parameter):
611 # parameter):
605
612
606 # alias parts echo first %s second %s
613 # alias parts echo first %s second %s
607
614
608 # will give you in IPython:
615 # will give you in IPython:
609 # >>> %parts A B
616 # >>> %parts A B
610 # first A second B
617 # first A second B
611
618
612 # Use one 'alias' statement per alias you wish to define.
619 # Use one 'alias' statement per alias you wish to define.
613
620
614 # alias
621 # alias
615
622
616 #************************* end of file <ipythonrc> ************************
623 #************************* end of file <ipythonrc> ************************
@@ -1,755 +1,755 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 IPython -- An enhanced Interactive Python
3 IPython -- An enhanced Interactive Python
4
4
5 Requires Python 2.1 or better.
5 Requires Python 2.1 or better.
6
6
7 This file contains the main make_IPython() starter function.
7 This file contains the main make_IPython() starter function.
8
8
9 $Id: ipmaker.py 1879 2006-11-04 00:34:34Z fptest $"""
9 $Id: ipmaker.py 1979 2006-12-12 18:50:20Z vivainio $"""
10
10
11 #*****************************************************************************
11 #*****************************************************************************
12 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
12 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
13 #
13 #
14 # Distributed under the terms of the BSD License. The full license is in
14 # Distributed under the terms of the BSD License. The full license is in
15 # the file COPYING, distributed as part of this software.
15 # the file COPYING, distributed as part of this software.
16 #*****************************************************************************
16 #*****************************************************************************
17
17
18 from IPython import Release
18 from IPython import Release
19 __author__ = '%s <%s>' % Release.authors['Fernando']
19 __author__ = '%s <%s>' % Release.authors['Fernando']
20 __license__ = Release.license
20 __license__ = Release.license
21 __version__ = Release.version
21 __version__ = Release.version
22
22
23 credits._Printer__data = """
23 credits._Printer__data = """
24 Python: %s
24 Python: %s
25
25
26 IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users.
26 IPython: Fernando Perez, Janko Hauser, Nathan Gray, and many users.
27 See http://ipython.scipy.org for more information.""" \
27 See http://ipython.scipy.org for more information.""" \
28 % credits._Printer__data
28 % credits._Printer__data
29
29
30 copyright._Printer__data += """
30 copyright._Printer__data += """
31
31
32 Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray.
32 Copyright (c) 2001-2004 Fernando Perez, Janko Hauser, Nathan Gray.
33 All Rights Reserved."""
33 All Rights Reserved."""
34
34
35 #****************************************************************************
35 #****************************************************************************
36 # Required modules
36 # Required modules
37
37
38 # From the standard library
38 # From the standard library
39 import __main__
39 import __main__
40 import __builtin__
40 import __builtin__
41 import os
41 import os
42 import re
42 import re
43 import sys
43 import sys
44 import types
44 import types
45 from pprint import pprint,pformat
45 from pprint import pprint,pformat
46
46
47 # Our own
47 # Our own
48 from IPython import DPyGetOpt
48 from IPython import DPyGetOpt
49 from IPython.ipstruct import Struct
49 from IPython.ipstruct import Struct
50 from IPython.OutputTrap import OutputTrap
50 from IPython.OutputTrap import OutputTrap
51 from IPython.ConfigLoader import ConfigLoader
51 from IPython.ConfigLoader import ConfigLoader
52 from IPython.iplib import InteractiveShell
52 from IPython.iplib import InteractiveShell
53 from IPython.usage import cmd_line_usage,interactive_usage
53 from IPython.usage import cmd_line_usage,interactive_usage
54 from IPython.genutils import *
54 from IPython.genutils import *
55
55
56 #-----------------------------------------------------------------------------
56 #-----------------------------------------------------------------------------
57 def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1,
57 def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1,
58 rc_override=None,shell_class=InteractiveShell,
58 rc_override=None,shell_class=InteractiveShell,
59 embedded=False,**kw):
59 embedded=False,**kw):
60 """This is a dump of IPython into a single function.
60 """This is a dump of IPython into a single function.
61
61
62 Later it will have to be broken up in a sensible manner.
62 Later it will have to be broken up in a sensible manner.
63
63
64 Arguments:
64 Arguments:
65
65
66 - argv: a list similar to sys.argv[1:]. It should NOT contain the desired
66 - argv: a list similar to sys.argv[1:]. It should NOT contain the desired
67 script name, b/c DPyGetOpt strips the first argument only for the real
67 script name, b/c DPyGetOpt strips the first argument only for the real
68 sys.argv.
68 sys.argv.
69
69
70 - user_ns: a dict to be used as the user's namespace."""
70 - user_ns: a dict to be used as the user's namespace."""
71
71
72 #----------------------------------------------------------------------
72 #----------------------------------------------------------------------
73 # Defaults and initialization
73 # Defaults and initialization
74
74
75 # For developer debugging, deactivates crash handler and uses pdb.
75 # For developer debugging, deactivates crash handler and uses pdb.
76 DEVDEBUG = False
76 DEVDEBUG = False
77
77
78 if argv is None:
78 if argv is None:
79 argv = sys.argv
79 argv = sys.argv
80
80
81 # __IP is the main global that lives throughout and represents the whole
81 # __IP is the main global that lives throughout and represents the whole
82 # application. If the user redefines it, all bets are off as to what
82 # application. If the user redefines it, all bets are off as to what
83 # happens.
83 # happens.
84
84
85 # __IP is the name of he global which the caller will have accessible as
85 # __IP is the name of he global which the caller will have accessible as
86 # __IP.name. We set its name via the first parameter passed to
86 # __IP.name. We set its name via the first parameter passed to
87 # InteractiveShell:
87 # InteractiveShell:
88
88
89 IP = shell_class('__IP',user_ns=user_ns,user_global_ns=user_global_ns,
89 IP = shell_class('__IP',user_ns=user_ns,user_global_ns=user_global_ns,
90 embedded=embedded,**kw)
90 embedded=embedded,**kw)
91
91
92 # Put 'help' in the user namespace
92 # Put 'help' in the user namespace
93 from site import _Helper
93 from site import _Helper
94 IP.user_ns['help'] = _Helper()
94 IP.user_ns['help'] = _Helper()
95
95
96
96
97 if DEVDEBUG:
97 if DEVDEBUG:
98 # For developer debugging only (global flag)
98 # For developer debugging only (global flag)
99 from IPython import ultraTB
99 from IPython import ultraTB
100 sys.excepthook = ultraTB.VerboseTB(call_pdb=1)
100 sys.excepthook = ultraTB.VerboseTB(call_pdb=1)
101
101
102 IP.BANNER_PARTS = ['Python %s\n'
102 IP.BANNER_PARTS = ['Python %s\n'
103 'Type "copyright", "credits" or "license" '
103 'Type "copyright", "credits" or "license" '
104 'for more information.\n'
104 'for more information.\n'
105 % (sys.version.split('\n')[0],),
105 % (sys.version.split('\n')[0],),
106 "IPython %s -- An enhanced Interactive Python."
106 "IPython %s -- An enhanced Interactive Python."
107 % (__version__,),
107 % (__version__,),
108 """? -> Introduction to IPython's features.
108 """? -> Introduction to IPython's features.
109 %magic -> Information about IPython's 'magic' % functions.
109 %magic -> Information about IPython's 'magic' % functions.
110 help -> Python's own help system.
110 help -> Python's own help system.
111 object? -> Details about 'object'. ?object also works, ?? prints more.
111 object? -> Details about 'object'. ?object also works, ?? prints more.
112 """ ]
112 """ ]
113
113
114 IP.usage = interactive_usage
114 IP.usage = interactive_usage
115
115
116 # Platform-dependent suffix and directory names. We use _ipython instead
116 # Platform-dependent suffix and directory names. We use _ipython instead
117 # of .ipython under win32 b/c there's software that breaks with .named
117 # of .ipython under win32 b/c there's software that breaks with .named
118 # directories on that platform.
118 # directories on that platform.
119 if os.name == 'posix':
119 if os.name == 'posix':
120 rc_suffix = ''
120 rc_suffix = ''
121 ipdir_def = '.ipython'
121 ipdir_def = '.ipython'
122 else:
122 else:
123 rc_suffix = '.ini'
123 rc_suffix = '.ini'
124 ipdir_def = '_ipython'
124 ipdir_def = '_ipython'
125
125
126 # default directory for configuration
126 # default directory for configuration
127 ipythondir_def = os.path.abspath(os.environ.get('IPYTHONDIR',
127 ipythondir_def = os.path.abspath(os.environ.get('IPYTHONDIR',
128 os.path.join(IP.home_dir,ipdir_def)))
128 os.path.join(IP.home_dir,ipdir_def)))
129
129
130 sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran
130 sys.path.insert(0, '') # add . to sys.path. Fix from Prabhu Ramachandran
131
131
132 # we need the directory where IPython itself is installed
132 # we need the directory where IPython itself is installed
133 import IPython
133 import IPython
134 IPython_dir = os.path.dirname(IPython.__file__)
134 IPython_dir = os.path.dirname(IPython.__file__)
135 del IPython
135 del IPython
136
136
137 #-------------------------------------------------------------------------
137 #-------------------------------------------------------------------------
138 # Command line handling
138 # Command line handling
139
139
140 # Valid command line options (uses DPyGetOpt syntax, like Perl's
140 # Valid command line options (uses DPyGetOpt syntax, like Perl's
141 # GetOpt::Long)
141 # GetOpt::Long)
142
142
143 # Any key not listed here gets deleted even if in the file (like session
143 # Any key not listed here gets deleted even if in the file (like session
144 # or profile). That's deliberate, to maintain the rc namespace clean.
144 # or profile). That's deliberate, to maintain the rc namespace clean.
145
145
146 # Each set of options appears twice: under _conv only the names are
146 # Each set of options appears twice: under _conv only the names are
147 # listed, indicating which type they must be converted to when reading the
147 # listed, indicating which type they must be converted to when reading the
148 # ipythonrc file. And under DPyGetOpt they are listed with the regular
148 # ipythonrc file. And under DPyGetOpt they are listed with the regular
149 # DPyGetOpt syntax (=s,=i,:f,etc).
149 # DPyGetOpt syntax (=s,=i,:f,etc).
150
150
151 # Make sure there's a space before each end of line (they get auto-joined!)
151 # Make sure there's a space before each end of line (they get auto-joined!)
152 cmdline_opts = ('autocall=i autoindent! automagic! banner! cache_size|cs=i '
152 cmdline_opts = ('autocall=i autoindent! automagic! banner! cache_size|cs=i '
153 'c=s classic|cl color_info! colors=s confirm_exit! '
153 'c=s classic|cl color_info! colors=s confirm_exit! '
154 'debug! deep_reload! editor=s log|l messages! nosep '
154 'debug! deep_reload! editor=s log|l messages! nosep '
155 'object_info_string_level=i pdb! '
155 'object_info_string_level=i pdb! '
156 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
156 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
157 'quick screen_length|sl=i prompts_pad_left=i '
157 'quick screen_length|sl=i prompts_pad_left=i '
158 'logfile|lf=s logplay|lp=s profile|p=s '
158 'logfile|lf=s logplay|lp=s profile|p=s '
159 'readline! readline_merge_completions! '
159 'readline! readline_merge_completions! '
160 'readline_omit__names! '
160 'readline_omit__names! '
161 'rcfile=s separate_in|si=s separate_out|so=s '
161 'rcfile=s separate_in|si=s separate_out|so=s '
162 'separate_out2|so2=s xmode=s wildcards_case_sensitive! '
162 'separate_out2|so2=s xmode=s wildcards_case_sensitive! '
163 'magic_docstrings system_verbose! '
163 'magic_docstrings system_verbose! '
164 'multi_line_specials! '
164 'multi_line_specials! '
165 'wxversion=s '
165 'wxversion=s '
166 'autoedit_syntax!')
166 'autoedit_syntax!')
167
167
168 # Options that can *only* appear at the cmd line (not in rcfiles).
168 # Options that can *only* appear at the cmd line (not in rcfiles).
169
169
170 # The "ignore" option is a kludge so that Emacs buffers don't crash, since
170 # The "ignore" option is a kludge so that Emacs buffers don't crash, since
171 # the 'C-c !' command in emacs automatically appends a -i option at the end.
171 # the 'C-c !' command in emacs automatically appends a -i option at the end.
172 cmdline_only = ('help ignore|i ipythondir=s Version upgrade '
172 cmdline_only = ('help ignore|i ipythondir=s Version upgrade '
173 'gthread! qthread! q4thread! wthread! pylab! tk!')
173 'gthread! qthread! q4thread! wthread! pylab! tk!')
174
174
175 # Build the actual name list to be used by DPyGetOpt
175 # Build the actual name list to be used by DPyGetOpt
176 opts_names = qw(cmdline_opts) + qw(cmdline_only)
176 opts_names = qw(cmdline_opts) + qw(cmdline_only)
177
177
178 # Set sensible command line defaults.
178 # Set sensible command line defaults.
179 # This should have everything from cmdline_opts and cmdline_only
179 # This should have everything from cmdline_opts and cmdline_only
180 opts_def = Struct(autocall = 1,
180 opts_def = Struct(autocall = 1,
181 autoedit_syntax = 0,
181 autoedit_syntax = 0,
182 autoindent = 0,
182 autoindent = 0,
183 automagic = 1,
183 automagic = 1,
184 banner = 1,
184 banner = 1,
185 cache_size = 1000,
185 cache_size = 1000,
186 c = '',
186 c = '',
187 classic = 0,
187 classic = 0,
188 colors = 'NoColor',
188 colors = 'NoColor',
189 color_info = 0,
189 color_info = 0,
190 confirm_exit = 1,
190 confirm_exit = 1,
191 debug = 0,
191 debug = 0,
192 deep_reload = 0,
192 deep_reload = 0,
193 editor = '0',
193 editor = '0',
194 help = 0,
194 help = 0,
195 ignore = 0,
195 ignore = 0,
196 ipythondir = ipythondir_def,
196 ipythondir = ipythondir_def,
197 log = 0,
197 log = 0,
198 logfile = '',
198 logfile = '',
199 logplay = '',
199 logplay = '',
200 multi_line_specials = 1,
200 multi_line_specials = 1,
201 messages = 1,
201 messages = 1,
202 object_info_string_level = 0,
202 object_info_string_level = 0,
203 nosep = 0,
203 nosep = 0,
204 pdb = 0,
204 pdb = 0,
205 pprint = 0,
205 pprint = 0,
206 profile = '',
206 profile = '',
207 prompt_in1 = 'In [\\#]: ',
207 prompt_in1 = 'In [\\#]: ',
208 prompt_in2 = ' .\\D.: ',
208 prompt_in2 = ' .\\D.: ',
209 prompt_out = 'Out[\\#]: ',
209 prompt_out = 'Out[\\#]: ',
210 prompts_pad_left = 1,
210 prompts_pad_left = 1,
211 quiet = 0,
211 quiet = 0,
212 quick = 0,
212 quick = 0,
213 readline = 1,
213 readline = 1,
214 readline_merge_completions = 1,
214 readline_merge_completions = 1,
215 readline_omit__names = 0,
215 readline_omit__names = 0,
216 rcfile = 'ipythonrc' + rc_suffix,
216 rcfile = 'ipythonrc' + rc_suffix,
217 screen_length = 0,
217 screen_length = 0,
218 separate_in = '\n',
218 separate_in = '\n',
219 separate_out = '\n',
219 separate_out = '\n',
220 separate_out2 = '',
220 separate_out2 = '',
221 system_header = 'IPython system call: ',
221 system_header = 'IPython system call: ',
222 system_verbose = 0,
222 system_verbose = 0,
223 gthread = 0,
223 gthread = 0,
224 qthread = 0,
224 qthread = 0,
225 q4thread = 0,
225 q4thread = 0,
226 wthread = 0,
226 wthread = 0,
227 pylab = 0,
227 pylab = 0,
228 tk = 0,
228 tk = 0,
229 upgrade = 0,
229 upgrade = 0,
230 Version = 0,
230 Version = 0,
231 xmode = 'Verbose',
231 xmode = 'Verbose',
232 wildcards_case_sensitive = 1,
232 wildcards_case_sensitive = 1,
233 wxversion = '0',
233 wxversion = '0',
234 magic_docstrings = 0, # undocumented, for doc generation
234 magic_docstrings = 0, # undocumented, for doc generation
235 )
235 )
236
236
237 # Things that will *only* appear in rcfiles (not at the command line).
237 # Things that will *only* appear in rcfiles (not at the command line).
238 # Make sure there's a space before each end of line (they get auto-joined!)
238 # Make sure there's a space before each end of line (they get auto-joined!)
239 rcfile_opts = { qwflat: 'include import_mod import_all execfile ',
239 rcfile_opts = { qwflat: 'include import_mod import_all execfile ',
240 qw_lol: 'import_some ',
240 qw_lol: 'import_some ',
241 # for things with embedded whitespace:
241 # for things with embedded whitespace:
242 list_strings:'execute alias readline_parse_and_bind ',
242 list_strings:'execute alias readline_parse_and_bind ',
243 # Regular strings need no conversion:
243 # Regular strings need no conversion:
244 None:'readline_remove_delims ',
244 None:'readline_remove_delims ',
245 }
245 }
246 # Default values for these
246 # Default values for these
247 rc_def = Struct(include = [],
247 rc_def = Struct(include = [],
248 import_mod = [],
248 import_mod = [],
249 import_all = [],
249 import_all = [],
250 import_some = [[]],
250 import_some = [[]],
251 execute = [],
251 execute = [],
252 execfile = [],
252 execfile = [],
253 alias = [],
253 alias = [],
254 readline_parse_and_bind = [],
254 readline_parse_and_bind = [],
255 readline_remove_delims = '',
255 readline_remove_delims = '',
256 )
256 )
257
257
258 # Build the type conversion dictionary from the above tables:
258 # Build the type conversion dictionary from the above tables:
259 typeconv = rcfile_opts.copy()
259 typeconv = rcfile_opts.copy()
260 typeconv.update(optstr2types(cmdline_opts))
260 typeconv.update(optstr2types(cmdline_opts))
261
261
262 # FIXME: the None key appears in both, put that back together by hand. Ugly!
262 # FIXME: the None key appears in both, put that back together by hand. Ugly!
263 typeconv[None] += ' ' + rcfile_opts[None]
263 typeconv[None] += ' ' + rcfile_opts[None]
264
264
265 # Remove quotes at ends of all strings (used to protect spaces)
265 # Remove quotes at ends of all strings (used to protect spaces)
266 typeconv[unquote_ends] = typeconv[None]
266 typeconv[unquote_ends] = typeconv[None]
267 del typeconv[None]
267 del typeconv[None]
268
268
269 # Build the list we'll use to make all config decisions with defaults:
269 # Build the list we'll use to make all config decisions with defaults:
270 opts_all = opts_def.copy()
270 opts_all = opts_def.copy()
271 opts_all.update(rc_def)
271 opts_all.update(rc_def)
272
272
273 # Build conflict resolver for recursive loading of config files:
273 # Build conflict resolver for recursive loading of config files:
274 # - preserve means the outermost file maintains the value, it is not
274 # - preserve means the outermost file maintains the value, it is not
275 # overwritten if an included file has the same key.
275 # overwritten if an included file has the same key.
276 # - add_flip applies + to the two values, so it better make sense to add
276 # - add_flip applies + to the two values, so it better make sense to add
277 # those types of keys. But it flips them first so that things loaded
277 # those types of keys. But it flips them first so that things loaded
278 # deeper in the inclusion chain have lower precedence.
278 # deeper in the inclusion chain have lower precedence.
279 conflict = {'preserve': ' '.join([ typeconv[int],
279 conflict = {'preserve': ' '.join([ typeconv[int],
280 typeconv[unquote_ends] ]),
280 typeconv[unquote_ends] ]),
281 'add_flip': ' '.join([ typeconv[qwflat],
281 'add_flip': ' '.join([ typeconv[qwflat],
282 typeconv[qw_lol],
282 typeconv[qw_lol],
283 typeconv[list_strings] ])
283 typeconv[list_strings] ])
284 }
284 }
285
285
286 # Now actually process the command line
286 # Now actually process the command line
287 getopt = DPyGetOpt.DPyGetOpt()
287 getopt = DPyGetOpt.DPyGetOpt()
288 getopt.setIgnoreCase(0)
288 getopt.setIgnoreCase(0)
289
289
290 getopt.parseConfiguration(opts_names)
290 getopt.parseConfiguration(opts_names)
291
291
292 try:
292 try:
293 getopt.processArguments(argv)
293 getopt.processArguments(argv)
294 except:
294 except:
295 print cmd_line_usage
295 print cmd_line_usage
296 warn('\nError in Arguments: ' + `sys.exc_value`)
296 warn('\nError in Arguments: ' + `sys.exc_value`)
297 sys.exit(1)
297 sys.exit(1)
298
298
299 # convert the options dict to a struct for much lighter syntax later
299 # convert the options dict to a struct for much lighter syntax later
300 opts = Struct(getopt.optionValues)
300 opts = Struct(getopt.optionValues)
301 args = getopt.freeValues
301 args = getopt.freeValues
302
302
303 # this is the struct (which has default values at this point) with which
303 # this is the struct (which has default values at this point) with which
304 # we make all decisions:
304 # we make all decisions:
305 opts_all.update(opts)
305 opts_all.update(opts)
306
306
307 # Options that force an immediate exit
307 # Options that force an immediate exit
308 if opts_all.help:
308 if opts_all.help:
309 page(cmd_line_usage)
309 page(cmd_line_usage)
310 sys.exit()
310 sys.exit()
311
311
312 if opts_all.Version:
312 if opts_all.Version:
313 print __version__
313 print __version__
314 sys.exit()
314 sys.exit()
315
315
316 if opts_all.magic_docstrings:
316 if opts_all.magic_docstrings:
317 IP.magic_magic('-latex')
317 IP.magic_magic('-latex')
318 sys.exit()
318 sys.exit()
319
319
320 # add personal ipythondir to sys.path so that users can put things in
320 # add personal ipythondir to sys.path so that users can put things in
321 # there for customization
321 # there for customization
322 sys.path.append(os.path.abspath(opts_all.ipythondir))
322 sys.path.append(os.path.abspath(opts_all.ipythondir))
323
323
324 # Create user config directory if it doesn't exist. This must be done
324 # Create user config directory if it doesn't exist. This must be done
325 # *after* getting the cmd line options.
325 # *after* getting the cmd line options.
326 if not os.path.isdir(opts_all.ipythondir):
326 if not os.path.isdir(opts_all.ipythondir):
327 IP.user_setup(opts_all.ipythondir,rc_suffix,'install')
327 IP.user_setup(opts_all.ipythondir,rc_suffix,'install')
328
328
329 # upgrade user config files while preserving a copy of the originals
329 # upgrade user config files while preserving a copy of the originals
330 if opts_all.upgrade:
330 if opts_all.upgrade:
331 IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade')
331 IP.user_setup(opts_all.ipythondir,rc_suffix,'upgrade')
332
332
333 # check mutually exclusive options in the *original* command line
333 # check mutually exclusive options in the *original* command line
334 mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'),
334 mutex_opts(opts,[qw('log logfile'),qw('rcfile profile'),
335 qw('classic profile'),qw('classic rcfile')])
335 qw('classic profile'),qw('classic rcfile')])
336
336
337 #---------------------------------------------------------------------------
337 #---------------------------------------------------------------------------
338 # Log replay
338 # Log replay
339
339
340 # if -logplay, we need to 'become' the other session. That basically means
340 # if -logplay, we need to 'become' the other session. That basically means
341 # replacing the current command line environment with that of the old
341 # replacing the current command line environment with that of the old
342 # session and moving on.
342 # session and moving on.
343
343
344 # this is needed so that later we know we're in session reload mode, as
344 # this is needed so that later we know we're in session reload mode, as
345 # opts_all will get overwritten:
345 # opts_all will get overwritten:
346 load_logplay = 0
346 load_logplay = 0
347
347
348 if opts_all.logplay:
348 if opts_all.logplay:
349 load_logplay = opts_all.logplay
349 load_logplay = opts_all.logplay
350 opts_debug_save = opts_all.debug
350 opts_debug_save = opts_all.debug
351 try:
351 try:
352 logplay = open(opts_all.logplay)
352 logplay = open(opts_all.logplay)
353 except IOError:
353 except IOError:
354 if opts_all.debug: IP.InteractiveTB()
354 if opts_all.debug: IP.InteractiveTB()
355 warn('Could not open logplay file '+`opts_all.logplay`)
355 warn('Could not open logplay file '+`opts_all.logplay`)
356 # restore state as if nothing had happened and move on, but make
356 # restore state as if nothing had happened and move on, but make
357 # sure that later we don't try to actually load the session file
357 # sure that later we don't try to actually load the session file
358 logplay = None
358 logplay = None
359 load_logplay = 0
359 load_logplay = 0
360 del opts_all.logplay
360 del opts_all.logplay
361 else:
361 else:
362 try:
362 try:
363 logplay.readline()
363 logplay.readline()
364 logplay.readline();
364 logplay.readline();
365 # this reloads that session's command line
365 # this reloads that session's command line
366 cmd = logplay.readline()[6:]
366 cmd = logplay.readline()[6:]
367 exec cmd
367 exec cmd
368 # restore the true debug flag given so that the process of
368 # restore the true debug flag given so that the process of
369 # session loading itself can be monitored.
369 # session loading itself can be monitored.
370 opts.debug = opts_debug_save
370 opts.debug = opts_debug_save
371 # save the logplay flag so later we don't overwrite the log
371 # save the logplay flag so later we don't overwrite the log
372 opts.logplay = load_logplay
372 opts.logplay = load_logplay
373 # now we must update our own structure with defaults
373 # now we must update our own structure with defaults
374 opts_all.update(opts)
374 opts_all.update(opts)
375 # now load args
375 # now load args
376 cmd = logplay.readline()[6:]
376 cmd = logplay.readline()[6:]
377 exec cmd
377 exec cmd
378 logplay.close()
378 logplay.close()
379 except:
379 except:
380 logplay.close()
380 logplay.close()
381 if opts_all.debug: IP.InteractiveTB()
381 if opts_all.debug: IP.InteractiveTB()
382 warn("Logplay file lacking full configuration information.\n"
382 warn("Logplay file lacking full configuration information.\n"
383 "I'll try to read it, but some things may not work.")
383 "I'll try to read it, but some things may not work.")
384
384
385 #-------------------------------------------------------------------------
385 #-------------------------------------------------------------------------
386 # set up output traps: catch all output from files, being run, modules
386 # set up output traps: catch all output from files, being run, modules
387 # loaded, etc. Then give it to the user in a clean form at the end.
387 # loaded, etc. Then give it to the user in a clean form at the end.
388
388
389 msg_out = 'Output messages. '
389 msg_out = 'Output messages. '
390 msg_err = 'Error messages. '
390 msg_err = 'Error messages. '
391 msg_sep = '\n'
391 msg_sep = '\n'
392 msg = Struct(config = OutputTrap('Configuration Loader',msg_out,
392 msg = Struct(config = OutputTrap('Configuration Loader',msg_out,
393 msg_err,msg_sep,debug,
393 msg_err,msg_sep,debug,
394 quiet_out=1),
394 quiet_out=1),
395 user_exec = OutputTrap('User File Execution',msg_out,
395 user_exec = OutputTrap('User File Execution',msg_out,
396 msg_err,msg_sep,debug),
396 msg_err,msg_sep,debug),
397 logplay = OutputTrap('Log Loader',msg_out,
397 logplay = OutputTrap('Log Loader',msg_out,
398 msg_err,msg_sep,debug),
398 msg_err,msg_sep,debug),
399 summary = ''
399 summary = ''
400 )
400 )
401
401
402 #-------------------------------------------------------------------------
402 #-------------------------------------------------------------------------
403 # Process user ipythonrc-type configuration files
403 # Process user ipythonrc-type configuration files
404
404
405 # turn on output trapping and log to msg.config
405 # turn on output trapping and log to msg.config
406 # remember that with debug on, trapping is actually disabled
406 # remember that with debug on, trapping is actually disabled
407 msg.config.trap_all()
407 msg.config.trap_all()
408
408
409 # look for rcfile in current or default directory
409 # look for rcfile in current or default directory
410 try:
410 try:
411 opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir)
411 opts_all.rcfile = filefind(opts_all.rcfile,opts_all.ipythondir)
412 except IOError:
412 except IOError:
413 if opts_all.debug: IP.InteractiveTB()
413 if opts_all.debug: IP.InteractiveTB()
414 warn('Configuration file %s not found. Ignoring request.'
414 warn('Configuration file %s not found. Ignoring request.'
415 % (opts_all.rcfile) )
415 % (opts_all.rcfile) )
416
416
417 # 'profiles' are a shorthand notation for config filenames
417 # 'profiles' are a shorthand notation for config filenames
418 if opts_all.profile:
418 if opts_all.profile:
419
419
420 try:
420 try:
421 opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile
421 opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile
422 + rc_suffix,
422 + rc_suffix,
423 opts_all.ipythondir)
423 opts_all.ipythondir)
424 except IOError:
424 except IOError:
425 if opts_all.debug: IP.InteractiveTB()
425 if opts_all.debug: IP.InteractiveTB()
426 opts.profile = '' # remove profile from options if invalid
426 opts.profile = '' # remove profile from options if invalid
427 # We won't warn anymore, primary method is ipy_profile_PROFNAME
427 # We won't warn anymore, primary method is ipy_profile_PROFNAME
428 # which does trigger a warning.
428 # which does trigger a warning.
429
429
430 # load the config file
430 # load the config file
431 rcfiledata = None
431 rcfiledata = None
432 if opts_all.quick:
432 if opts_all.quick:
433 print 'Launching IPython in quick mode. No config file read.'
433 print 'Launching IPython in quick mode. No config file read.'
434 elif opts_all.classic:
434 elif opts_all.classic:
435 print 'Launching IPython in classic mode. No config file read.'
435 print 'Launching IPython in classic mode. No config file read.'
436 elif opts_all.rcfile:
436 elif opts_all.rcfile:
437 try:
437 try:
438 cfg_loader = ConfigLoader(conflict)
438 cfg_loader = ConfigLoader(conflict)
439 rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv,
439 rcfiledata = cfg_loader.load(opts_all.rcfile,typeconv,
440 'include',opts_all.ipythondir,
440 'include',opts_all.ipythondir,
441 purge = 1,
441 purge = 1,
442 unique = conflict['preserve'])
442 unique = conflict['preserve'])
443 except:
443 except:
444 IP.InteractiveTB()
444 IP.InteractiveTB()
445 warn('Problems loading configuration file '+
445 warn('Problems loading configuration file '+
446 `opts_all.rcfile`+
446 `opts_all.rcfile`+
447 '\nStarting with default -bare bones- configuration.')
447 '\nStarting with default -bare bones- configuration.')
448 else:
448 else:
449 warn('No valid configuration file found in either currrent directory\n'+
449 warn('No valid configuration file found in either currrent directory\n'+
450 'or in the IPython config. directory: '+`opts_all.ipythondir`+
450 'or in the IPython config. directory: '+`opts_all.ipythondir`+
451 '\nProceeding with internal defaults.')
451 '\nProceeding with internal defaults.')
452
452
453 #------------------------------------------------------------------------
453 #------------------------------------------------------------------------
454 # Set exception handlers in mode requested by user.
454 # Set exception handlers in mode requested by user.
455 otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode
455 otrap = OutputTrap(trap_out=1) # trap messages from magic_xmode
456 IP.magic_xmode(opts_all.xmode)
456 IP.magic_xmode(opts_all.xmode)
457 otrap.release_out()
457 otrap.release_out()
458
458
459 #------------------------------------------------------------------------
459 #------------------------------------------------------------------------
460 # Execute user config
460 # Execute user config
461
461
462 # Create a valid config structure with the right precedence order:
462 # Create a valid config structure with the right precedence order:
463 # defaults < rcfile < command line. This needs to be in the instance, so
463 # defaults < rcfile < command line. This needs to be in the instance, so
464 # that method calls below that rely on it find it.
464 # that method calls below that rely on it find it.
465 IP.rc = rc_def.copy()
465 IP.rc = rc_def.copy()
466
466
467 # Work with a local alias inside this routine to avoid unnecessary
467 # Work with a local alias inside this routine to avoid unnecessary
468 # attribute lookups.
468 # attribute lookups.
469 IP_rc = IP.rc
469 IP_rc = IP.rc
470
470
471 IP_rc.update(opts_def)
471 IP_rc.update(opts_def)
472 if rcfiledata:
472 if rcfiledata:
473 # now we can update
473 # now we can update
474 IP_rc.update(rcfiledata)
474 IP_rc.update(rcfiledata)
475 IP_rc.update(opts)
475 IP_rc.update(opts)
476 IP_rc.update(rc_override)
476 IP_rc.update(rc_override)
477
477
478 # Store the original cmd line for reference:
478 # Store the original cmd line for reference:
479 IP_rc.opts = opts
479 IP_rc.opts = opts
480 IP_rc.args = args
480 IP_rc.args = args
481
481
482 # create a *runtime* Struct like rc for holding parameters which may be
482 # create a *runtime* Struct like rc for holding parameters which may be
483 # created and/or modified by runtime user extensions.
483 # created and/or modified by runtime user extensions.
484 IP.runtime_rc = Struct()
484 IP.runtime_rc = Struct()
485
485
486 # from this point on, all config should be handled through IP_rc,
486 # from this point on, all config should be handled through IP_rc,
487 # opts* shouldn't be used anymore.
487 # opts* shouldn't be used anymore.
488
488
489
489
490 # update IP_rc with some special things that need manual
490 # update IP_rc with some special things that need manual
491 # tweaks. Basically options which affect other options. I guess this
491 # tweaks. Basically options which affect other options. I guess this
492 # should just be written so that options are fully orthogonal and we
492 # should just be written so that options are fully orthogonal and we
493 # wouldn't worry about this stuff!
493 # wouldn't worry about this stuff!
494
494
495 if IP_rc.classic:
495 if IP_rc.classic:
496 IP_rc.quick = 1
496 IP_rc.quick = 1
497 IP_rc.cache_size = 0
497 IP_rc.cache_size = 0
498 IP_rc.pprint = 0
498 IP_rc.pprint = 0
499 IP_rc.prompt_in1 = '>>> '
499 IP_rc.prompt_in1 = '>>> '
500 IP_rc.prompt_in2 = '... '
500 IP_rc.prompt_in2 = '... '
501 IP_rc.prompt_out = ''
501 IP_rc.prompt_out = ''
502 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
502 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
503 IP_rc.colors = 'NoColor'
503 IP_rc.colors = 'NoColor'
504 IP_rc.xmode = 'Plain'
504 IP_rc.xmode = 'Plain'
505
505
506 IP.pre_config_initialization()
506 IP.pre_config_initialization()
507 # configure readline
507 # configure readline
508 # Define the history file for saving commands in between sessions
508 # Define the history file for saving commands in between sessions
509 if IP_rc.profile:
509 if IP_rc.profile:
510 histfname = 'history-%s' % IP_rc.profile
510 histfname = 'history-%s' % IP_rc.profile
511 else:
511 else:
512 histfname = 'history'
512 histfname = 'history'
513 IP.histfile = os.path.join(opts_all.ipythondir,histfname)
513 IP.histfile = os.path.join(opts_all.ipythondir,histfname)
514
514
515 # update exception handlers with rc file status
515 # update exception handlers with rc file status
516 otrap.trap_out() # I don't want these messages ever.
516 otrap.trap_out() # I don't want these messages ever.
517 IP.magic_xmode(IP_rc.xmode)
517 IP.magic_xmode(IP_rc.xmode)
518 otrap.release_out()
518 otrap.release_out()
519
519
520 # activate logging if requested and not reloading a log
520 # activate logging if requested and not reloading a log
521 if IP_rc.logplay:
521 if IP_rc.logplay:
522 IP.magic_logstart(IP_rc.logplay + ' append')
522 IP.magic_logstart(IP_rc.logplay + ' append')
523 elif IP_rc.logfile:
523 elif IP_rc.logfile:
524 IP.magic_logstart(IP_rc.logfile)
524 IP.magic_logstart(IP_rc.logfile)
525 elif IP_rc.log:
525 elif IP_rc.log:
526 IP.magic_logstart()
526 IP.magic_logstart()
527
527
528 # find user editor so that it we don't have to look it up constantly
528 # find user editor so that it we don't have to look it up constantly
529 if IP_rc.editor.strip()=='0':
529 if IP_rc.editor.strip()=='0':
530 try:
530 try:
531 ed = os.environ['EDITOR']
531 ed = os.environ['EDITOR']
532 except KeyError:
532 except KeyError:
533 if os.name == 'posix':
533 if os.name == 'posix':
534 ed = 'vi' # the only one guaranteed to be there!
534 ed = 'vi' # the only one guaranteed to be there!
535 else:
535 else:
536 ed = 'notepad' # same in Windows!
536 ed = 'notepad' # same in Windows!
537 IP_rc.editor = ed
537 IP_rc.editor = ed
538
538
539 # Keep track of whether this is an embedded instance or not (useful for
539 # Keep track of whether this is an embedded instance or not (useful for
540 # post-mortems).
540 # post-mortems).
541 IP_rc.embedded = IP.embedded
541 IP_rc.embedded = IP.embedded
542
542
543 # Recursive reload
543 # Recursive reload
544 try:
544 try:
545 from IPython import deep_reload
545 from IPython import deep_reload
546 if IP_rc.deep_reload:
546 if IP_rc.deep_reload:
547 __builtin__.reload = deep_reload.reload
547 __builtin__.reload = deep_reload.reload
548 else:
548 else:
549 __builtin__.dreload = deep_reload.reload
549 __builtin__.dreload = deep_reload.reload
550 del deep_reload
550 del deep_reload
551 except ImportError:
551 except ImportError:
552 pass
552 pass
553
553
554 # Save the current state of our namespace so that the interactive shell
554 # Save the current state of our namespace so that the interactive shell
555 # can later know which variables have been created by us from config files
555 # can later know which variables have been created by us from config files
556 # and loading. This way, loading a file (in any way) is treated just like
556 # and loading. This way, loading a file (in any way) is treated just like
557 # defining things on the command line, and %who works as expected.
557 # defining things on the command line, and %who works as expected.
558
558
559 # DON'T do anything that affects the namespace beyond this point!
559 # DON'T do anything that affects the namespace beyond this point!
560 IP.internal_ns.update(__main__.__dict__)
560 IP.internal_ns.update(__main__.__dict__)
561
561
562 #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who
562 #IP.internal_ns.update(locals()) # so our stuff doesn't show up in %who
563
563
564 # Now run through the different sections of the users's config
564 # Now run through the different sections of the users's config
565 if IP_rc.debug:
565 if IP_rc.debug:
566 print 'Trying to execute the following configuration structure:'
566 print 'Trying to execute the following configuration structure:'
567 print '(Things listed first are deeper in the inclusion tree and get'
567 print '(Things listed first are deeper in the inclusion tree and get'
568 print 'loaded first).\n'
568 print 'loaded first).\n'
569 pprint(IP_rc.__dict__)
569 pprint(IP_rc.__dict__)
570
570
571 for mod in IP_rc.import_mod:
571 for mod in IP_rc.import_mod:
572 try:
572 try:
573 exec 'import '+mod in IP.user_ns
573 exec 'import '+mod in IP.user_ns
574 except :
574 except :
575 IP.InteractiveTB()
575 IP.InteractiveTB()
576 import_fail_info(mod)
576 import_fail_info(mod)
577
577
578 for mod_fn in IP_rc.import_some:
578 for mod_fn in IP_rc.import_some:
579 if mod_fn == []: break
579 if not mod_fn == []:
580 mod,fn = mod_fn[0],','.join(mod_fn[1:])
580 mod,fn = mod_fn[0],','.join(mod_fn[1:])
581 try:
581 try:
582 exec 'from '+mod+' import '+fn in IP.user_ns
582 exec 'from '+mod+' import '+fn in IP.user_ns
583 except :
583 except :
584 IP.InteractiveTB()
584 IP.InteractiveTB()
585 import_fail_info(mod,fn)
585 import_fail_info(mod,fn)
586
586
587 for mod in IP_rc.import_all:
587 for mod in IP_rc.import_all:
588 try:
588 try:
589 exec 'from '+mod+' import *' in IP.user_ns
589 exec 'from '+mod+' import *' in IP.user_ns
590 except :
590 except :
591 IP.InteractiveTB()
591 IP.InteractiveTB()
592 import_fail_info(mod)
592 import_fail_info(mod)
593
593
594 for code in IP_rc.execute:
594 for code in IP_rc.execute:
595 try:
595 try:
596 exec code in IP.user_ns
596 exec code in IP.user_ns
597 except:
597 except:
598 IP.InteractiveTB()
598 IP.InteractiveTB()
599 warn('Failure executing code: ' + `code`)
599 warn('Failure executing code: ' + `code`)
600
600
601 # Execute the files the user wants in ipythonrc
601 # Execute the files the user wants in ipythonrc
602 for file in IP_rc.execfile:
602 for file in IP_rc.execfile:
603 try:
603 try:
604 file = filefind(file,sys.path+[IPython_dir])
604 file = filefind(file,sys.path+[IPython_dir])
605 except IOError:
605 except IOError:
606 warn(itpl('File $file not found. Skipping it.'))
606 warn(itpl('File $file not found. Skipping it.'))
607 else:
607 else:
608 IP.safe_execfile(os.path.expanduser(file),IP.user_ns)
608 IP.safe_execfile(os.path.expanduser(file),IP.user_ns)
609
609
610 # finally, try importing ipy_*_conf for final configuration
610 # finally, try importing ipy_*_conf for final configuration
611 try:
611 try:
612 import ipy_system_conf
612 import ipy_system_conf
613 except ImportError:
613 except ImportError:
614 if opts_all.debug: IP.InteractiveTB()
614 if opts_all.debug: IP.InteractiveTB()
615 warn("Could not import 'ipy_system_conf'")
615 warn("Could not import 'ipy_system_conf'")
616 except:
616 except:
617 IP.InteractiveTB()
617 IP.InteractiveTB()
618 import_fail_info('ipy_system_conf')
618 import_fail_info('ipy_system_conf')
619
619
620 if opts_all.profile:
620 if opts_all.profile:
621 profmodname = 'ipy_profile_' + opts_all.profile
621 profmodname = 'ipy_profile_' + opts_all.profile
622 try:
622 try:
623 __import__(profmodname)
623 __import__(profmodname)
624 except ImportError:
624 except ImportError:
625 # only warn if ipythonrc-PROFNAME didn't exist
625 # only warn if ipythonrc-PROFNAME didn't exist
626 if opts.profile =='':
626 if opts.profile =='':
627 warn("Could not start with profile '%s'!\n"
627 warn("Could not start with profile '%s'!\n"
628 "('%s/%s.py' does not exist? run '%%upgrade')" %
628 "('%s/%s.py' does not exist? run '%%upgrade')" %
629 (opts_all.profile, opts_all.ipythondir, profmodname) )
629 (opts_all.profile, opts_all.ipythondir, profmodname) )
630 except:
630 except:
631 print "Error importing",profmodname
631 print "Error importing",profmodname
632 IP.InteractiveTB()
632 IP.InteractiveTB()
633 import_fail_info(profmodname)
633 import_fail_info(profmodname)
634
634
635 try:
635 try:
636 import ipy_user_conf
636 import ipy_user_conf
637 except ImportError:
637 except ImportError:
638 if opts_all.debug: IP.InteractiveTB()
638 if opts_all.debug: IP.InteractiveTB()
639 warn("Could not import user config!\n "
639 warn("Could not import user config!\n "
640 "('%s/ipy_user_conf.py' does not exist? Please run '%%upgrade')\n"
640 "('%s/ipy_user_conf.py' does not exist? Please run '%%upgrade')\n"
641 % opts_all.ipythondir)
641 % opts_all.ipythondir)
642 except:
642 except:
643 print "Error importing ipy_user_conf"
643 print "Error importing ipy_user_conf"
644 IP.InteractiveTB()
644 IP.InteractiveTB()
645 import_fail_info("ipy_user_conf")
645 import_fail_info("ipy_user_conf")
646
646
647 # release stdout and stderr and save config log into a global summary
647 # release stdout and stderr and save config log into a global summary
648 msg.config.release_all()
648 msg.config.release_all()
649 if IP_rc.messages:
649 if IP_rc.messages:
650 msg.summary += msg.config.summary_all()
650 msg.summary += msg.config.summary_all()
651
651
652 #------------------------------------------------------------------------
652 #------------------------------------------------------------------------
653 # Setup interactive session
653 # Setup interactive session
654
654
655 # Now we should be fully configured. We can then execute files or load
655 # Now we should be fully configured. We can then execute files or load
656 # things only needed for interactive use. Then we'll open the shell.
656 # things only needed for interactive use. Then we'll open the shell.
657
657
658 # Take a snapshot of the user namespace before opening the shell. That way
658 # Take a snapshot of the user namespace before opening the shell. That way
659 # we'll be able to identify which things were interactively defined and
659 # we'll be able to identify which things were interactively defined and
660 # which were defined through config files.
660 # which were defined through config files.
661 IP.user_config_ns = IP.user_ns.copy()
661 IP.user_config_ns = IP.user_ns.copy()
662
662
663 # Force reading a file as if it were a session log. Slower but safer.
663 # Force reading a file as if it were a session log. Slower but safer.
664 if load_logplay:
664 if load_logplay:
665 print 'Replaying log...'
665 print 'Replaying log...'
666 try:
666 try:
667 if IP_rc.debug:
667 if IP_rc.debug:
668 logplay_quiet = 0
668 logplay_quiet = 0
669 else:
669 else:
670 logplay_quiet = 1
670 logplay_quiet = 1
671
671
672 msg.logplay.trap_all()
672 msg.logplay.trap_all()
673 IP.safe_execfile(load_logplay,IP.user_ns,
673 IP.safe_execfile(load_logplay,IP.user_ns,
674 islog = 1, quiet = logplay_quiet)
674 islog = 1, quiet = logplay_quiet)
675 msg.logplay.release_all()
675 msg.logplay.release_all()
676 if IP_rc.messages:
676 if IP_rc.messages:
677 msg.summary += msg.logplay.summary_all()
677 msg.summary += msg.logplay.summary_all()
678 except:
678 except:
679 warn('Problems replaying logfile %s.' % load_logplay)
679 warn('Problems replaying logfile %s.' % load_logplay)
680 IP.InteractiveTB()
680 IP.InteractiveTB()
681
681
682 # Load remaining files in command line
682 # Load remaining files in command line
683 msg.user_exec.trap_all()
683 msg.user_exec.trap_all()
684
684
685 # Do NOT execute files named in the command line as scripts to be loaded
685 # Do NOT execute files named in the command line as scripts to be loaded
686 # by embedded instances. Doing so has the potential for an infinite
686 # by embedded instances. Doing so has the potential for an infinite
687 # recursion if there are exceptions thrown in the process.
687 # recursion if there are exceptions thrown in the process.
688
688
689 # XXX FIXME: the execution of user files should be moved out to after
689 # XXX FIXME: the execution of user files should be moved out to after
690 # ipython is fully initialized, just as if they were run via %run at the
690 # ipython is fully initialized, just as if they were run via %run at the
691 # ipython prompt. This would also give them the benefit of ipython's
691 # ipython prompt. This would also give them the benefit of ipython's
692 # nice tracebacks.
692 # nice tracebacks.
693
693
694 if (not embedded and IP_rc.args and
694 if (not embedded and IP_rc.args and
695 not IP_rc.args[0].lower().endswith('.ipy')):
695 not IP_rc.args[0].lower().endswith('.ipy')):
696 name_save = IP.user_ns['__name__']
696 name_save = IP.user_ns['__name__']
697 IP.user_ns['__name__'] = '__main__'
697 IP.user_ns['__name__'] = '__main__'
698 # Set our own excepthook in case the user code tries to call it
698 # Set our own excepthook in case the user code tries to call it
699 # directly. This prevents triggering the IPython crash handler.
699 # directly. This prevents triggering the IPython crash handler.
700 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
700 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
701
701
702 save_argv = sys.argv[1:] # save it for later restoring
702 save_argv = sys.argv[1:] # save it for later restoring
703
703
704 sys.argv = args
704 sys.argv = args
705
705
706 try:
706 try:
707 IP.safe_execfile(args[0], IP.user_ns)
707 IP.safe_execfile(args[0], IP.user_ns)
708 finally:
708 finally:
709 # Reset our crash handler in place
709 # Reset our crash handler in place
710 sys.excepthook = old_excepthook
710 sys.excepthook = old_excepthook
711 sys.argv[:] = save_argv
711 sys.argv[:] = save_argv
712 IP.user_ns['__name__'] = name_save
712 IP.user_ns['__name__'] = name_save
713
713
714 msg.user_exec.release_all()
714 msg.user_exec.release_all()
715
715
716 if IP_rc.messages:
716 if IP_rc.messages:
717 msg.summary += msg.user_exec.summary_all()
717 msg.summary += msg.user_exec.summary_all()
718
718
719 # since we can't specify a null string on the cmd line, 0 is the equivalent:
719 # since we can't specify a null string on the cmd line, 0 is the equivalent:
720 if IP_rc.nosep:
720 if IP_rc.nosep:
721 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
721 IP_rc.separate_in = IP_rc.separate_out = IP_rc.separate_out2 = '0'
722 if IP_rc.separate_in == '0': IP_rc.separate_in = ''
722 if IP_rc.separate_in == '0': IP_rc.separate_in = ''
723 if IP_rc.separate_out == '0': IP_rc.separate_out = ''
723 if IP_rc.separate_out == '0': IP_rc.separate_out = ''
724 if IP_rc.separate_out2 == '0': IP_rc.separate_out2 = ''
724 if IP_rc.separate_out2 == '0': IP_rc.separate_out2 = ''
725 IP_rc.separate_in = IP_rc.separate_in.replace('\\n','\n')
725 IP_rc.separate_in = IP_rc.separate_in.replace('\\n','\n')
726 IP_rc.separate_out = IP_rc.separate_out.replace('\\n','\n')
726 IP_rc.separate_out = IP_rc.separate_out.replace('\\n','\n')
727 IP_rc.separate_out2 = IP_rc.separate_out2.replace('\\n','\n')
727 IP_rc.separate_out2 = IP_rc.separate_out2.replace('\\n','\n')
728
728
729 # Determine how many lines at the bottom of the screen are needed for
729 # Determine how many lines at the bottom of the screen are needed for
730 # showing prompts, so we can know wheter long strings are to be printed or
730 # showing prompts, so we can know wheter long strings are to be printed or
731 # paged:
731 # paged:
732 num_lines_bot = IP_rc.separate_in.count('\n')+1
732 num_lines_bot = IP_rc.separate_in.count('\n')+1
733 IP_rc.screen_length = IP_rc.screen_length - num_lines_bot
733 IP_rc.screen_length = IP_rc.screen_length - num_lines_bot
734
734
735 # configure startup banner
735 # configure startup banner
736 if IP_rc.c: # regular python doesn't print the banner with -c
736 if IP_rc.c: # regular python doesn't print the banner with -c
737 IP_rc.banner = 0
737 IP_rc.banner = 0
738 if IP_rc.banner:
738 if IP_rc.banner:
739 BANN_P = IP.BANNER_PARTS
739 BANN_P = IP.BANNER_PARTS
740 else:
740 else:
741 BANN_P = []
741 BANN_P = []
742
742
743 if IP_rc.profile: BANN_P.append('IPython profile: %s\n' % IP_rc.profile)
743 if IP_rc.profile: BANN_P.append('IPython profile: %s\n' % IP_rc.profile)
744
744
745 # add message log (possibly empty)
745 # add message log (possibly empty)
746 if msg.summary: BANN_P.append(msg.summary)
746 if msg.summary: BANN_P.append(msg.summary)
747 # Final banner is a string
747 # Final banner is a string
748 IP.BANNER = '\n'.join(BANN_P)
748 IP.BANNER = '\n'.join(BANN_P)
749
749
750 # Finalize the IPython instance. This assumes the rc structure is fully
750 # Finalize the IPython instance. This assumes the rc structure is fully
751 # in place.
751 # in place.
752 IP.post_config_initialization()
752 IP.post_config_initialization()
753
753
754 return IP
754 return IP
755 #************************ end of file <ipmaker.py> **************************
755 #************************ end of file <ipmaker.py> **************************
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now