##// END OF EJS Templates
improve callable alias inspection
vivainio -
Show More
@@ -31,8 +31,17 b' def main():'
31
31
32 # beefed up %env is handy in shell mode
32 # beefed up %env is handy in shell mode
33 import envpersist
33 import envpersist
34
35 # To see where mycmd resides (in path/aliases), do %which mycmd
34 import ipy_which
36 import ipy_which
37
38 # tab completers for hg, svn, ...
35 import ipy_app_completers
39 import ipy_app_completers
40
41 # To make executables foo and bar in mybin usable without PATH change, do:
42 # %rehashdir c:/mybin
43 # %store foo
44 # %store bar
36 import ipy_rehashdir
45 import ipy_rehashdir
37 import ipy_signals
46 import ipy_signals
38
47
@@ -48,7 +57,7 b' def main():'
48 from IPython import Release
57 from IPython import Release
49
58
50 import sys
59 import sys
51 # I like my banner minimal.
60 # Non-chatty banner
52 o.banner = "IPython %s [on Py %s]\n" % (Release.version,sys.version.split(None,1)[0])
61 o.banner = "IPython %s [on Py %s]\n" % (Release.version,sys.version.split(None,1)[0])
53
62
54
63
@@ -26,6 +26,12 b' def which_alias(fname):'
26 for al, tgt in ip.IP.alias_table.items():
26 for al, tgt in ip.IP.alias_table.items():
27 if not (al == fname or fnmatch(al, fname)):
27 if not (al == fname or fnmatch(al, fname)):
28 continue
28 continue
29 if callable(tgt):
30 print "Callable alias",tgt
31 d = tgt.__doc__
32 if d:
33 print "Docstring:\n",d
34 continue
29 trg = tgt[1]
35 trg = tgt[1]
30
36
31 trans = ip.expand_alias(trg)
37 trans = ip.expand_alias(trg)
@@ -6,7 +6,7 b' Uses syntax highlighting for presenting the various information elements.'
6 Similar in spirit to the inspect module, but all calls take a name argument to
6 Similar in spirit to the inspect module, but all calls take a name argument to
7 reference the name under which an object is being read.
7 reference the name under which an object is being read.
8
8
9 $Id: OInspect.py 2597 2007-08-08 22:41:02Z fperez $
9 $Id: OInspect.py 2717 2007-09-05 19:49:42Z vivainio $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -341,9 +341,14 b' class Inspector:'
341 # Get docstring, special-casing aliases:
341 # Get docstring, special-casing aliases:
342 if isalias:
342 if isalias:
343 if not callable(obj):
343 if not callable(obj):
344 ds = "Alias to the system command:\n %s" % obj[1]
344 try:
345 ds = "Alias to the system command:\n %s" % obj[1]
346 except:
347 ds = "Alias: " + str(obj)
345 else:
348 else:
346 ds = "Alias to " + str(obj)
349 ds = "Alias to " + str(obj)
350 if obj.__doc__:
351 ds += "\nDocstring:\n" + obj.__doc__
347 else:
352 else:
348 ds = getdoc(obj)
353 ds = getdoc(obj)
349 if ds is None:
354 if ds is None:
@@ -13,7 +13,9 b''
13
13
14 * Extensions/ipy_profile_sh.py: Try to detect cygwin on win32,
14 * Extensions/ipy_profile_sh.py: Try to detect cygwin on win32,
15 if not available load ipy_fsops.py for cp, mv, etc. replacements
15 if not available load ipy_fsops.py for cp, mv, etc. replacements
16
16
17 * OInspect.py, ipy_which.py: improve %which and obj? for callable
18 aliases
17
19
18 2007-09-04 Ville Vainio <vivainio@gmail.com>
20 2007-09-04 Ville Vainio <vivainio@gmail.com>
19
21
General Comments 0
You need to be logged in to leave comments. Login now