home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import IPython.ipapi as IPython
- ip = IPython.ipapi.get()
- import os
- import sys
- from fnmatch import fnmatch
-
- def which(fname):
- fullpath = filter(os.path.isdir, os.environ['PATH'].split(os.pathsep))
- if '.' not in fullpath:
- fullpath = [
- '.'] + fullpath
-
- fn = fname
- for p in fullpath:
- for f in os.listdir(p):
- (head, ext) = os.path.splitext(f)
- if f == fn or fnmatch(head, fn):
- yield os.path.join(p, f)
- continue
-
-
-
-
- def which_alias(fname):
- for al, tgt in ip.IP.alias_table.items():
- if not al == fname or fnmatch(al, fname):
- continue
-
- if callable(tgt):
- print 'Callable alias', tgt
- d = tgt.__doc__
- if d:
- print 'Docstring:\n', d
- continue
-
-
- trg = tgt[1]
- trans = ip.expand_alias(trg)
- cmd = trans.split(None, 1)[0]
- print al, '->', trans
- for realcmd in which(cmd):
- print ' ==', realcmd
-
-
-
-
- def which_f(self, arg):
- which_alias(arg)
- for e in which(arg):
- print e
-
-
- ip.expose_magic('which', which_f)
-