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 2 |
|
4 | $Id: Magic.py 2917 2007-12-31 14:11:34Z 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 | |
@@ -2239,10 +2239,24 b' Currently the magic system has the following functions:\\n"""' | |||||
2239 | if isinstance(data,Macro): |
|
2239 | if isinstance(data,Macro): | |
2240 | self._edit_macro(args,data) |
|
2240 | self._edit_macro(args,data) | |
2241 | return |
|
2241 | return | |
2242 |
|
2242 | |||
2243 | # For objects, try to edit the file where they are defined |
|
2243 | # For objects, try to edit the file where they are defined | |
2244 | try: |
|
2244 | try: | |
2245 | filename = inspect.getabsfile(data) |
|
2245 | filename = inspect.getabsfile(data) | |
|
2246 | if 'fakemodule' in filename.lower() and inspect.isclass(data): | |||
|
2247 | # class created by %edit? Try to find source | |||
|
2248 | # by looking for method definitions instead, the | |||
|
2249 | # __module__ in those classes is FakeModule. | |||
|
2250 | attrs = [getattr(data, aname) for aname in dir(data)] | |||
|
2251 | for attr in attrs: | |||
|
2252 | if not inspect.ismethod(attr): | |||
|
2253 | continue | |||
|
2254 | filename = inspect.getabsfile(attr) | |||
|
2255 | if filename and 'fakemodule' not in filename.lower(): | |||
|
2256 | # change the attribute to be the edit target instead | |||
|
2257 | data = attr | |||
|
2258 | break | |||
|
2259 | ||||
2246 | datafile = 1 |
|
2260 | datafile = 1 | |
2247 | except TypeError: |
|
2261 | except TypeError: | |
2248 | filename = make_filename(args) |
|
2262 | filename = make_filename(args) |
General Comments 0
You need to be logged in to leave comments.
Login now