DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (b66b287a2650)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
"""
Run a python script, adding extra directories to the python path.
"""

import sys, os

def usage():
    print >>sys.stderr, "pythonpath.py -I directory script.py [args...]"
    sys.exit(150)

paths = []

while True:
    try:
        arg = sys.argv[1]
    except IndexError:
        usage()

    if arg == '-I':
        del sys.argv[1]
        try:
            path = sys.argv.pop(1)
        except IndexError:
            usage()

        paths.append(path)
        continue

    if arg.startswith('-I'):
        path = sys.argv.pop(1)[2:]
        paths.append(path)
        continue

    break

sys.argv.pop(0)
script = sys.argv[0]

sys.path[0:0] = [os.path.dirname(script)] + paths
execfile(script, {'__name__': '__main__', '__file__': script})