Show More
@@ -6,7 +6,7 b' Uses syntax highlighting for presenting the various information elements.' | |||
|
6 | 6 | Similar in spirit to the inspect module, but all calls take a name argument to |
|
7 | 7 | reference the name under which an object is being read. |
|
8 | 8 | |
|
9 |
$Id: OInspect.py 13 |
|
|
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 | 107 | self.write('\n') |
|
108 | 108 | |
|
109 | 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 | 112 | self.color_table = color_table |
|
112 | 113 | self.parser = PyColorize.Parser(code_color_table,out='str') |
|
113 | 114 | self.format = self.parser.format |
|
115 | self.str_detail_level = str_detail_level | |
|
114 | 116 | self.set_active_scheme(scheme) |
|
115 | 117 | |
|
116 | 118 | def __getargspec(self,obj): |
@@ -302,21 +304,22 b' class Inspector:' | |||
|
302 | 304 | except: pass |
|
303 | 305 | |
|
304 | 306 | # String form, but snip if too long in ? form (full in ??) |
|
305 | try: | |
|
306 |
|
|
|
307 |
str |
|
|
308 | if not detail_level and len(ostr)>string_max: | |
|
309 | ostr = ostr[:shalf] + ' <...> ' + ostr[-shalf:] | |
|
310 | ostr = ("\n" + " " * len(str_head.expandtabs())).\ | |
|
311 | join(map(string.strip,ostr.split("\n"))) | |
|
312 | if ostr.find('\n') > -1: | |
|
313 | # Print multi-line strings starting at the next line. | |
|
314 | str_sep = '\n' | |
|
315 | else: | |
|
316 |
|
|
|
317 | out.writeln("%s%s%s" % (header(str_head),str_sep,ostr)) | |
|
318 | except: | |
|
319 |
|
|
|
307 | if detail_level >= self.str_detail_level: | |
|
308 | try: | |
|
309 | ostr = str(obj) | |
|
310 | str_head = 'String Form:' | |
|
311 | if not detail_level and len(ostr)>string_max: | |
|
312 | ostr = ostr[:shalf] + ' <...> ' + ostr[-shalf:] | |
|
313 | ostr = ("\n" + " " * len(str_head.expandtabs())).\ | |
|
314 | join(map(string.strip,ostr.split("\n"))) | |
|
315 | if ostr.find('\n') > -1: | |
|
316 | # Print multi-line strings starting at the next line. | |
|
317 | str_sep = '\n' | |
|
318 | else: | |
|
319 | str_sep = '\t' | |
|
320 | out.writeln("%s%s%s" % (header(str_head),str_sep,ostr)) | |
|
321 | except: | |
|
322 | pass | |
|
320 | 323 | |
|
321 | 324 | if ospace: |
|
322 | 325 | out.writeln(header('Namespace:\t')+ospace) |
@@ -1,5 +1,5 b'' | |||
|
1 | 1 | # -*- Mode: Shell-Script -*- Not really, but shows comments correctly |
|
2 |
# $Id: ipythonrc 132 |
|
|
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 | 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 | 312 | # xmode - Exception reporting mode. |
|
303 | 313 | |
|
304 | 314 | # Valid modes: Plain, Context and Verbose. |
@@ -6,7 +6,7 b' Requires Python 2.3 or newer.' | |||
|
6 | 6 | |
|
7 | 7 | This file contains all the classes and helper functions specific to IPython. |
|
8 | 8 | |
|
9 |
$Id: iplib.py 132 |
|
|
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 | 537 | # and add any custom exception handlers the user may have specified |
|
538 | 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 | 540 | # indentation management |
|
545 | 541 | self.autoindent = False |
|
546 | 542 | self.indent_current_nsp = 0 |
@@ -607,6 +603,12 b' class InteractiveShell(object,Magic):' | |||
|
607 | 603 | 'finalize' the initialization.""" |
|
608 | 604 | |
|
609 | 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 | 613 | # Load readline proper |
|
612 | 614 | if rc.readline: |
@@ -1874,9 +1876,6 b' want to merge them back into the new files.""" % locals()' | |||
|
1874 | 1876 | rewritten = pre + rewritten # add indentation |
|
1875 | 1877 | return self.handle_normal(rewritten) |
|
1876 | 1878 | |
|
1877 | ||
|
1878 | ||
|
1879 | ||
|
1880 | 1879 | #print 'pre <%s> iFun <%s> rest <%s>' % (pre,iFun,theRest) # dbg |
|
1881 | 1880 | |
|
1882 | 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 | 1940 | # in this case, all that's left is either an alias or |
|
1942 | 1941 | # processing the line normally. |
|
1943 | 1942 | if iFun in self.alias_table: |
|
1944 | return self.handle_alias(line,continue_prompt, | |
|
1945 | pre,iFun,theRest) | |
|
1943 | # if autocall is off, by not running _ofind we won't know | |
|
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 | 1956 | else: |
|
1948 | 1957 | return self.handle_normal(line,continue_prompt) |
@@ -6,7 +6,7 b' Requires Python 2.1 or better.' | |||
|
6 | 6 | |
|
7 | 7 | This file contains the main make_IPython() starter function. |
|
8 | 8 | |
|
9 |
$Id: ipmaker.py 132 |
|
|
9 | $Id: ipmaker.py 1329 2006-05-26 07:52:45Z fperez $""" | |
|
10 | 10 | |
|
11 | 11 | #***************************************************************************** |
|
12 | 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 | 155 | # Make sure there's a space before each end of line (they get auto-joined!) |
|
156 | 156 | cmdline_opts = ('autocall=i autoindent! automagic! banner! cache_size|cs=i ' |
|
157 | 157 | 'c=s classic|cl color_info! colors=s confirm_exit! ' |
|
158 |
'debug! deep_reload! editor=s log|l messages! nosep |
|
|
158 | 'debug! deep_reload! editor=s log|l messages! nosep ' | |
|
159 | 'object_info_string_level=i pdb! ' | |
|
159 | 160 | 'pprint! prompt_in1|pi1=s prompt_in2|pi2=s prompt_out|po=s ' |
|
160 | 161 | 'quick screen_length|sl=i prompts_pad_left=i ' |
|
161 | 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 | 203 | logplay = '', |
|
203 | 204 | multi_line_specials = 1, |
|
204 | 205 | messages = 1, |
|
206 | object_info_string_level = 0, | |
|
205 | 207 | nosep = 0, |
|
206 | 208 | pdb = 0, |
|
207 | 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 | 16 | 2006-05-25 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2 | 17 | |
|
3 | 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