##// END OF EJS Templates
allow %edit ClassName if the class was created by '%edit' (look for the source file from method objs instead of class obj). Closes #132
vivainio -
Show More
@@ -1,7 +1,7 b''
1 1 # -*- coding: utf-8 -*-
2 2 """Magic functions for InteractiveShell.
3 3
4 $Id: Magic.py 2899 2007-12-28 08:32:59Z fperez $"""
4 $Id: Magic.py 2917 2007-12-31 14:11:34Z vivainio $"""
5 5
6 6 #*****************************************************************************
7 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 2239 if isinstance(data,Macro):
2240 2240 self._edit_macro(args,data)
2241 2241 return
2242
2242
2243 2243 # For objects, try to edit the file where they are defined
2244 2244 try:
2245 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 2260 datafile = 1
2247 2261 except TypeError:
2248 2262 filename = make_filename(args)
General Comments 0
You need to be logged in to leave comments. Login now