##// END OF EJS Templates
- fix bug where aliases would shadow variables when autocall was fully off....
fperez -
Show More
@@ -6,7 +6,7 b' Uses syntax highlighting for presenting the various information elements.'
6 Similar in spirit to the inspect module, but all calls take a name argument to
6 Similar in spirit to the inspect module, but all calls take a name argument to
7 reference the name under which an object is being read.
7 reference the name under which an object is being read.
8
8
9 $Id: OInspect.py 1300 2006-05-15 16:27:36Z vivainio $
9 $Id: OInspect.py 1329 2006-05-26 07:52:45Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -107,10 +107,12 b' class myStringIO(StringIO.StringIO):'
107 self.write('\n')
107 self.write('\n')
108
108
109 class Inspector:
109 class Inspector:
110 def __init__(self,color_table,code_color_table,scheme):
110 def __init__(self,color_table,code_color_table,scheme,
111 str_detail_level=0):
111 self.color_table = color_table
112 self.color_table = color_table
112 self.parser = PyColorize.Parser(code_color_table,out='str')
113 self.parser = PyColorize.Parser(code_color_table,out='str')
113 self.format = self.parser.format
114 self.format = self.parser.format
115 self.str_detail_level = str_detail_level
114 self.set_active_scheme(scheme)
116 self.set_active_scheme(scheme)
115
117
116 def __getargspec(self,obj):
118 def __getargspec(self,obj):
@@ -302,21 +304,22 b' class Inspector:'
302 except: pass
304 except: pass
303
305
304 # String form, but snip if too long in ? form (full in ??)
306 # String form, but snip if too long in ? form (full in ??)
305 try:
307 if detail_level >= self.str_detail_level:
306 ostr = str(obj)
308 try:
307 str_head = 'String Form:'
309 ostr = str(obj)
308 if not detail_level and len(ostr)>string_max:
310 str_head = 'String Form:'
309 ostr = ostr[:shalf] + ' <...> ' + ostr[-shalf:]
311 if not detail_level and len(ostr)>string_max:
310 ostr = ("\n" + " " * len(str_head.expandtabs())).\
312 ostr = ostr[:shalf] + ' <...> ' + ostr[-shalf:]
311 join(map(string.strip,ostr.split("\n")))
313 ostr = ("\n" + " " * len(str_head.expandtabs())).\
312 if ostr.find('\n') > -1:
314 join(map(string.strip,ostr.split("\n")))
313 # Print multi-line strings starting at the next line.
315 if ostr.find('\n') > -1:
314 str_sep = '\n'
316 # Print multi-line strings starting at the next line.
315 else:
317 str_sep = '\n'
316 str_sep = '\t'
318 else:
317 out.writeln("%s%s%s" % (header(str_head),str_sep,ostr))
319 str_sep = '\t'
318 except:
320 out.writeln("%s%s%s" % (header(str_head),str_sep,ostr))
319 pass
321 except:
322 pass
320
323
321 if ospace:
324 if ospace:
322 out.writeln(header('Namespace:\t')+ospace)
325 out.writeln(header('Namespace:\t')+ospace)
@@ -1,5 +1,5 b''
1 # -*- Mode: Shell-Script -*- Not really, but shows comments correctly
1 # -*- Mode: Shell-Script -*- Not really, but shows comments correctly
2 # $Id: ipythonrc 1324 2006-05-24 20:25:11Z fperez $
2 # $Id: ipythonrc 1329 2006-05-26 07:52:45Z fperez $
3
3
4 #***************************************************************************
4 #***************************************************************************
5 #
5 #
@@ -299,6 +299,16 b' nosep 0'
299
299
300 wildcards_case_sensitive 1
300 wildcards_case_sensitive 1
301
301
302 # 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,
304 # 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
306 # computed (there is no X??? level of detail). This is mostly of use to
307 # people who frequently manipulate objects whose string representation is
308 # extremely expensive to compute.
309
310 object_info_string_level 0
311
302 # xmode - Exception reporting mode.
312 # xmode - Exception reporting mode.
303
313
304 # Valid modes: Plain, Context and Verbose.
314 # Valid modes: Plain, Context and Verbose.
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.'
6
6
7 This file contains all the classes and helper functions specific to IPython.
7 This file contains all the classes and helper functions specific to IPython.
8
8
9 $Id: iplib.py 1326 2006-05-25 02:07:11Z fperez $
9 $Id: iplib.py 1329 2006-05-26 07:52:45Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -537,10 +537,6 b' class InteractiveShell(object,Magic):'
537 # and add any custom exception handlers the user may have specified
537 # and add any custom exception handlers the user may have specified
538 self.set_custom_exc(*custom_exceptions)
538 self.set_custom_exc(*custom_exceptions)
539
539
540 # Object inspector
541 self.inspector = OInspect.Inspector(OInspect.InspectColors,
542 PyColorize.ANSICodeColors,
543 'NoColor')
544 # indentation management
540 # indentation management
545 self.autoindent = False
541 self.autoindent = False
546 self.indent_current_nsp = 0
542 self.indent_current_nsp = 0
@@ -607,6 +603,12 b' class InteractiveShell(object,Magic):'
607 'finalize' the initialization."""
603 'finalize' the initialization."""
608
604
609 rc = self.rc
605 rc = self.rc
606
607 # Object inspector
608 self.inspector = OInspect.Inspector(OInspect.InspectColors,
609 PyColorize.ANSICodeColors,
610 'NoColor',
611 rc.object_info_string_level)
610
612
611 # Load readline proper
613 # Load readline proper
612 if rc.readline:
614 if rc.readline:
@@ -1874,9 +1876,6 b' want to merge them back into the new files.""" % locals()'
1874 rewritten = pre + rewritten # add indentation
1876 rewritten = pre + rewritten # add indentation
1875 return self.handle_normal(rewritten)
1877 return self.handle_normal(rewritten)
1876
1878
1877
1878
1879
1880 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1879 #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg
1881
1880
1882 # First check for explicit escapes in the last/first character
1881 # First check for explicit escapes in the last/first character
@@ -1941,8 +1940,18 b' want to merge them back into the new files.""" % locals()'
1941 # in this case, all that's left is either an alias or
1940 # in this case, all that's left is either an alias or
1942 # processing the line normally.
1941 # processing the line normally.
1943 if iFun in self.alias_table:
1942 if iFun in self.alias_table:
1944 return self.handle_alias(line,continue_prompt,
1943 # if autocall is off, by not running _ofind we won't know
1945 pre,iFun,theRest)
1944 # whether the given name may also exist in one of the
1945 # user's namespace. At this point, it's best to do a
1946 # quick check just to be sure that we don't let aliases
1947 # shadow variables.
1948 head = iFun.split('.',1)[0]
1949 if head in self.user_ns or head in self.internal_ns \
1950 or head in __builtin__.__dict__:
1951 return self.handle_normal(line,continue_prompt)
1952 else:
1953 return self.handle_alias(line,continue_prompt,
1954 pre,iFun,theRest)
1946
1955
1947 else:
1956 else:
1948 return self.handle_normal(line,continue_prompt)
1957 return self.handle_normal(line,continue_prompt)
@@ -6,7 +6,7 b' 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 1328 2006-05-25 07:47:56Z fperez $"""
9 $Id: ipmaker.py 1329 2006-05-26 07:52:45Z fperez $"""
10
10
11 #*****************************************************************************
11 #*****************************************************************************
12 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
12 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
@@ -155,7 +155,8 b" object? -> Details about 'object'. ?object also works, ?? prints more."
155 # Make sure there's a space before each end of line (they get auto-joined!)
155 # Make sure there's a space before each end of line (they get auto-joined!)
156 cmdline_opts = ('autocall=i autoindent! automagic! banner! cache_size|cs=i '
156 cmdline_opts = ('autocall=i autoindent! automagic! banner! cache_size|cs=i '
157 'c=s classic|cl color_info! colors=s confirm_exit! '
157 'c=s classic|cl color_info! colors=s confirm_exit! '
158 'debug! deep_reload! editor=s log|l messages! nosep pdb! '
158 'debug! deep_reload! editor=s log|l messages! nosep '
159 'object_info_string_level=i pdb! '
159 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
160 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s '
160 'quick screen_length|sl=i prompts_pad_left=i '
161 'quick screen_length|sl=i prompts_pad_left=i '
161 'logfile|lf=s logplay|lp=s profile|p=s '
162 'logfile|lf=s logplay|lp=s profile|p=s '
@@ -202,6 +203,7 b" object? -> Details about 'object'. ?object also works, ?? prints more."
202 logplay = '',
203 logplay = '',
203 multi_line_specials = 1,
204 multi_line_specials = 1,
204 messages = 1,
205 messages = 1,
206 object_info_string_level = 0,
205 nosep = 0,
207 nosep = 0,
206 pdb = 0,
208 pdb = 0,
207 pprint = 0,
209 pprint = 0,
@@ -1,3 +1,18 b''
1 2006-05-26 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/iplib.py (_prefilter): fix bug where aliases would
4 shadow variables when autocall was fully off. Reported by SAGE
5 author William Stein.
6
7 * IPython/OInspect.py (Inspector.__init__): add a flag to control
8 at what detail level strings are computed when foo? is requested.
9 This allows users to ask for example that the string form of an
10 object is only computed when foo?? is called, or even never, by
11 setting the object_info_string_level >= 2 in the configuration
12 file. This new option has been added and documented. After a
13 request by SAGE to be able to control the printing of very large
14 objects more easily.
15
1 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
16 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu>
2
17
3 * IPython/ipmaker.py (make_IPython): remove the ipython call path
18 * IPython/ipmaker.py (make_IPython): remove the ipython call path
General Comments 0
You need to be logged in to leave comments. Login now