Show More
@@ -1,7 +1,7 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """Magic functions for InteractiveShell. |
|
2 | """Magic functions for InteractiveShell. | |
3 |
|
3 | |||
4 |
$Id: Magic.py 13 |
|
4 | $Id: Magic.py 1380 2006-06-27 11:34:39Z vivainio $""" | |
5 |
|
5 | |||
6 | #***************************************************************************** |
|
6 | #***************************************************************************** | |
7 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and |
|
7 | # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and | |
@@ -195,7 +195,7 b' license. To use profiling, please install"python2.3-profiler" from non-free.""")' | |||||
195 |
|
195 | |||
196 | # initialize results to 'null' |
|
196 | # initialize results to 'null' | |
197 | found = 0; obj = None; ospace = None; ds = None; |
|
197 | found = 0; obj = None; ospace = None; ds = None; | |
198 | ismagic = 0; isalias = 0 |
|
198 | ismagic = 0; isalias = 0; parent = None | |
199 |
|
199 | |||
200 | # Look for the given name by splitting it in parts. If the head is |
|
200 | # Look for the given name by splitting it in parts. If the head is | |
201 | # found, then we look for all the remaining parts as members, and only |
|
201 | # found, then we look for all the remaining parts as members, and only | |
@@ -210,6 +210,7 b' license. To use profiling, please install"python2.3-profiler" from non-free.""")' | |||||
210 | else: |
|
210 | else: | |
211 | for part in oname_rest: |
|
211 | for part in oname_rest: | |
212 | try: |
|
212 | try: | |
|
213 | parent = obj | |||
213 | obj = getattr(obj,part) |
|
214 | obj = getattr(obj,part) | |
214 | except: |
|
215 | except: | |
215 | # Blanket except b/c some badly implemented objects |
|
216 | # Blanket except b/c some badly implemented objects | |
@@ -241,7 +242,7 b' license. To use profiling, please install"python2.3-profiler" from non-free.""")' | |||||
241 | ospace = 'Interactive' |
|
242 | ospace = 'Interactive' | |
242 |
|
243 | |||
243 | return {'found':found, 'obj':obj, 'namespace':ospace, |
|
244 | return {'found':found, 'obj':obj, 'namespace':ospace, | |
244 | 'ismagic':ismagic, 'isalias':isalias} |
|
245 | 'ismagic':ismagic, 'isalias':isalias, 'parent':parent} | |
245 |
|
246 | |||
246 | def arg_err(self,func): |
|
247 | def arg_err(self,func): | |
247 | """Print docstring if incorrect arguments were passed""" |
|
248 | """Print docstring if incorrect arguments were passed""" | |
@@ -632,7 +633,24 b' Currently the magic system has the following functions:\\n"""' | |||||
632 |
|
633 | |||
633 | oname = oname.strip() |
|
634 | oname = oname.strip() | |
634 | info = Struct(self._ofind(oname)) |
|
635 | info = Struct(self._ofind(oname)) | |
|
636 | ||||
635 | if info.found: |
|
637 | if info.found: | |
|
638 | # Get the docstring of the class property if it exists. | |||
|
639 | path = oname.split('.') | |||
|
640 | root = '.'.join(path[:-1]) | |||
|
641 | if info.parent is not None: | |||
|
642 | try: | |||
|
643 | target = getattr(info.parent, '__class__') | |||
|
644 | # The object belongs to a class instance. | |||
|
645 | try: | |||
|
646 | target = getattr(target, path[-1]) | |||
|
647 | # The class defines the object. | |||
|
648 | if isinstance(target, property): | |||
|
649 | oname = root + '.__class__.' + path[-1] | |||
|
650 | info = Struct(self._ofind(oname)) | |||
|
651 | except AttributeError: pass | |||
|
652 | except AttributeError: pass | |||
|
653 | ||||
636 | pmethod = getattr(self.shell.inspector,meth) |
|
654 | pmethod = getattr(self.shell.inspector,meth) | |
637 | formatter = info.ismagic and self.format_screen or None |
|
655 | formatter = info.ismagic and self.format_screen or None | |
638 | if meth == 'pdoc': |
|
656 | if meth == 'pdoc': |
General Comments 0
You need to be logged in to leave comments.
Login now