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 re
- import fnmatch
- import sys
-
- def selflaunch(ip, line):
- tup = line.split(None, 1)
- if len(tup) == 1:
- print 'Launching nested ipython session'
- os.system(sys.executable)
- return None
- cmd = sys.executable + ' ' + tup[1]
- print '>', cmd
- os.system(cmd)
-
-
- class PyLauncher:
-
- def __init__(self, script):
- self.script = os.path.abspath(script)
-
-
- def __call__(self, ip, line):
- if self.script.endswith('.ipy'):
- ip.runlines(open(self.script).read())
- else:
- tup = line.split(None, 1)
- if len(tup) == 2:
- tail = ' ' + tup[1]
- else:
- tail = ''
- selflaunch(ip, 'py ' + self.script + tail)
-
-
- def __repr__(self):
- return 'PyLauncher("%s")' % self.script
-
-
-
- def rehashdir_f(self, arg):
-
- def isjunk(fname):
- junk = [
- '*~']
- for j in junk:
- if fnmatch.fnmatch(fname, j):
- return True
-
- return False
-
- created = []
- if not arg:
- arg = '.'
-
- path = map(os.path.abspath, arg.split(';'))
- alias_table = self.shell.alias_table
- savedir = os.getcwd()
-
- try:
- if os.name == 'posix':
- for pdir in path:
- os.chdir(pdir)
- for ff in os.listdir(pdir):
- if isexec(ff) and not isjunk(ff):
- src = os.path.splitext(ff)[0]
- tgt = os.path.abspath(ff)
- created.append(src)
- alias_table[src] = (0, tgt)
- continue
- None if os.name == 'posix' else (None,)
-
-
- else:
- for pdir in path:
- os.chdir(pdir)
- for ff in os.listdir(pdir):
- if isexec(ff) and not isjunk(ff):
- src = execre.sub('\\1', ff)
- tgt = os.path.abspath(ff)
- src = src.lower()
- created.append(src)
- alias_table[src] = (0, tgt)
- continue
-
-
- self.shell.alias_table_validate()
- finally:
- os.chdir(savedir)
-
- return created
-
- ip.expose_magic('rehashdir', rehashdir_f)
-