Remove temporary diagnostics (b=605754 r=dmandelin a=betaN+
[mozilla-central.git] / config / pythonpath.py
blobcc47db42fd91c06cf458c2fa53910ce2a803a80c
1 """
2 Run a python script, adding extra directories to the python path.
3 """
5 import sys, os
7 def usage():
8 print >>sys.stderr, "pythonpath.py -I directory script.py [args...]"
9 sys.exit(150)
11 paths = []
13 while True:
14 try:
15 arg = sys.argv[1]
16 except IndexError:
17 usage()
19 if arg == '-I':
20 del sys.argv[1]
21 try:
22 path = sys.argv.pop(1)
23 except IndexError:
24 usage()
26 paths.append(path)
27 continue
29 if arg.startswith('-I'):
30 path = sys.argv.pop(1)[2:]
31 paths.append(path)
32 continue
34 break
36 sys.argv.pop(0)
37 script = sys.argv[0]
39 sys.path[0:0] = [os.path.dirname(script)] + paths
40 execfile(script, {'__name__': '__main__', '__file__': script})