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 1 |
|
|
9 | $Id: OInspect.py 1300 2006-05-15 16:27:36Z vivainio $ | |
|
10 | 10 | """ |
|
11 | 11 | |
|
12 | 12 | #***************************************************************************** |
@@ -29,7 +29,7 b' import linecache' | |||
|
29 | 29 | import string |
|
30 | 30 | import StringIO |
|
31 | 31 | import types |
|
32 | ||
|
32 | import os | |
|
33 | 33 | # IPython's own |
|
34 | 34 | from IPython import PyColorize |
|
35 | 35 | from IPython.genutils import page,indent,Term,mkdict |
@@ -239,6 +239,8 b' class Inspector:' | |||
|
239 | 239 | |
|
240 | 240 | if (ofile.endswith('.so') or ofile.endswith('.dll')): |
|
241 | 241 | print 'File %r is binary, not printing.' % ofile |
|
242 | elif not os.path.isfile(ofile): | |
|
243 | print 'File %r does not exist, not printing.' % ofile | |
|
242 | 244 | else: |
|
243 | 245 | # Print only text files, not extension binaries. |
|
244 | 246 | page(self.format(open(ofile).read()),lineno) |
@@ -331,7 +333,8 b' class Inspector:' | |||
|
331 | 333 | fname = inspect.getabsfile(obj) |
|
332 | 334 | if fname.endswith('<string>'): |
|
333 | 335 | fname = 'Dynamically generated function. No source code available.' |
|
334 |
if fname.endswith('.so') or fname.endswith('.dll') |
|
|
336 | if (fname.endswith('.so') or fname.endswith('.dll') or | |
|
337 | not os.path.isfile(fname)): | |
|
335 | 338 | binary_file = True |
|
336 | 339 | out.writeln(header('File:\t\t')+fname) |
|
337 | 340 | except: |
@@ -349,17 +352,22 b' class Inspector:' | |||
|
349 | 352 | if ds and detail_level == 0: |
|
350 | 353 | out.writeln(header('Docstring:\n') + indent(ds)) |
|
351 | 354 | |
|
355 | ||
|
352 | 356 | # Original source code for any callable |
|
353 | 357 | if detail_level: |
|
354 | 358 | # Flush the source cache because inspect can return out-of-date source |
|
355 | 359 | linecache.checkcache() |
|
360 | source_success = False | |
|
356 | 361 | try: |
|
357 | 362 | if not binary_file: |
|
358 | 363 | source = self.format(inspect.getsource(obj)) |
|
359 | 364 | out.write(header('Source:\n')+source.rstrip()) |
|
365 | source_success = True | |
|
360 | 366 | except: |
|
361 |
|
|
|
362 | out.writeln(header('Docstring:\n') + indent(ds)) | |
|
367 | pass | |
|
368 | ||
|
369 | if ds and not source_success: | |
|
370 | out.writeln(header('Docstring [source file open failed]:\n') + indent(ds)) | |
|
363 | 371 | |
|
364 | 372 | # Constructor docstring for classes |
|
365 | 373 | if obj_type is types.ClassType: |
@@ -1,6 +1,12 b'' | |||
|
1 | 2006-05-15 Ville Vainio <vivainio@gmail.com> | |
|
2 | ||
|
3 | * Oinspect.py: Only show docstring for nonexisting/binary files | |
|
4 | when doing object??, closing ticket #62 | |
|
5 | ||
|
6 | ||
|
1 | 7 | 2006-05-13 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2 | 8 | |
|
3 |
* IPython |
|
|
9 | * IPython/Shell.py (MTInteractiveShell.runsource): Fix threading | |
|
4 | 10 | bug, closes http://www.scipy.net/roundup/ipython/issue55. A lock |
|
5 | 11 | was being released in a routine which hadn't checked if it had |
|
6 | 12 | been the one to acquire it. |
General Comments 0
You need to be logged in to leave comments.
Login now