Show More
@@ -24,13 +24,14 b" __all__ = ['Inspector','InspectColors']" | |||
|
24 | 24 | |
|
25 | 25 | # stdlib modules |
|
26 | 26 | import __builtin__ |
|
27 | import StringIO | |
|
27 | 28 | import inspect |
|
28 | 29 | import linecache |
|
29 | import string | |
|
30 | import StringIO | |
|
31 | import types | |
|
32 | 30 | import os |
|
31 | import string | |
|
33 | 32 | import sys |
|
33 | import types | |
|
34 | ||
|
34 | 35 | # IPython's own |
|
35 | 36 | from IPython import PyColorize |
|
36 | 37 | from IPython.genutils import page,indent,Term |
@@ -136,6 +137,7 b' def getdoc(obj):' | |||
|
136 | 137 | ds = '%s\n%s' % (ds,ds2) |
|
137 | 138 | return ds |
|
138 | 139 | |
|
140 | ||
|
139 | 141 | def getsource(obj,is_binary=False): |
|
140 | 142 | """Wrapper around inspect.getsource. |
|
141 | 143 | |
@@ -162,26 +164,7 b' def getsource(obj,is_binary=False):' | |||
|
162 | 164 | src = inspect.getsource(obj.__class__) |
|
163 | 165 | return src |
|
164 | 166 | |
|
165 | #**************************************************************************** | |
|
166 | # Class definitions | |
|
167 | ||
|
168 | class myStringIO(StringIO.StringIO): | |
|
169 | """Adds a writeln method to normal StringIO.""" | |
|
170 | def writeln(self,*arg,**kw): | |
|
171 | """Does a write() and then a write('\n')""" | |
|
172 | self.write(*arg,**kw) | |
|
173 | self.write('\n') | |
|
174 | ||
|
175 | class Inspector: | |
|
176 | def __init__(self,color_table,code_color_table,scheme, | |
|
177 | str_detail_level=0): | |
|
178 | self.color_table = color_table | |
|
179 | self.parser = PyColorize.Parser(code_color_table,out='str') | |
|
180 | self.format = self.parser.format | |
|
181 | self.str_detail_level = str_detail_level | |
|
182 | self.set_active_scheme(scheme) | |
|
183 | ||
|
184 | def __getargspec(self,obj): | |
|
167 | def getargspec(obj): | |
|
185 | 168 |
|
|
186 | 169 | |
|
187 | 170 |
|
@@ -201,6 +184,26 b' class Inspector:' | |||
|
201 | 184 |
|
|
202 | 185 |
|
|
203 | 186 | |
|
187 | #**************************************************************************** | |
|
188 | # Class definitions | |
|
189 | ||
|
190 | class myStringIO(StringIO.StringIO): | |
|
191 | """Adds a writeln method to normal StringIO.""" | |
|
192 | def writeln(self,*arg,**kw): | |
|
193 | """Does a write() and then a write('\n')""" | |
|
194 | self.write(*arg,**kw) | |
|
195 | self.write('\n') | |
|
196 | ||
|
197 | ||
|
198 | class Inspector: | |
|
199 | def __init__(self,color_table,code_color_table,scheme, | |
|
200 | str_detail_level=0): | |
|
201 | self.color_table = color_table | |
|
202 | self.parser = PyColorize.Parser(code_color_table,out='str') | |
|
203 | self.format = self.parser.format | |
|
204 | self.str_detail_level = str_detail_level | |
|
205 | self.set_active_scheme(scheme) | |
|
206 | ||
|
204 | 207 | def __getdef(self,obj,oname=''): |
|
205 | 208 | """Return the definition header for any callable object. |
|
206 | 209 | |
@@ -208,7 +211,7 b' class Inspector:' | |||
|
208 | 211 | exception is suppressed.""" |
|
209 | 212 | |
|
210 | 213 | try: |
|
211 |
return oname + inspect.formatargspec(* |
|
|
214 | return oname + inspect.formatargspec(*getargspec(obj)) | |
|
212 | 215 | except: |
|
213 | 216 | return None |
|
214 | 217 |
General Comments 0
You need to be logged in to leave comments.
Login now