##// END OF EJS Templates
add ipy_extutil.py
vivainio -
Show More
@@ -0,0 +1,43 b''
1 """ IPython extension management tools.
2
3 After installation, you'll have the 'extutil' object in your namespace.
4 to.
5 """
6
7 # for the purposes of this module, every module that has the name 'ip' globally
8 # installed as below is an IPython extension
9
10 import IPython.ipapi
11 ip = IPython.ipapi.get()
12
13 import sys,textwrap,inspect
14
15 def indent(s, ind= ' '):
16 return '\n'.join([ind +l for l in s.splitlines()])
17
18 class ExtUtil:
19 """ IPython extensios (ipy_* etc.) management utilities """
20
21 def describe(self):
22 for n,mod in self._active():
23 doc = inspect.getdoc(mod)
24 if doc:
25 print '== %s ==' % n
26 print indent(doc)
27
28
29 def ls(self):
30 """ Show list of installed extensions. """
31 for n,m in self._active():
32 print '%-20s %s' % (n,m.__file__.replace('\\','/'))
33 def _active(self):
34 act = []
35 for mname,m in sys.modules.items():
36 o = getattr(m, 'ip', None)
37 if isinstance(o, IPython.ipapi.IPApi):
38 act.append((mname,m))
39 act.sort()
40 return act
41
42 extutil = ExtUtil()
43 ip.to_user_ns('extutil')
@@ -1,3 +1,8 b''
1 2007-04-21 Ville Vainio <vivainio@gmail.com>
2
3 * Extensions/ipy_extutil.py: added extension to manage other ipython
4 extensions. Now only supports 'ls' == list extensions.
5
1 6 2007-04-20 Fernando Perez <Fernando.Perez@colorado.edu>
2 7
3 8 * IPython/Debugger.py (BdbQuit_excepthook): fix small bug that
General Comments 0
You need to be logged in to leave comments. Login now