176
|
1 #!/usr/bin/env python
|
|
2
|
|
3 import os
|
|
4 import sys
|
|
5
|
170
|
6 def findInPath(fileName, path=os.environ['PATH']):
|
|
7 """python equivalent of which; should really be in the stdlib"""
|
|
8 dirs = path.split(os.pathsep)
|
|
9 for dir in dirs:
|
|
10 if os.path.isfile(os.path.join(dir, fileName)):
|
|
11 return os.path.join(dir, fileName)
|
176
|
12 if os.path.isfile(os.path.join(dir, fileName + ".exe")):
|
|
13 return os.path.join(dir, fileName + ".exe")
|
170
|
14
|
|
15 if __name__ == '__main__':
|
|
16 for i in sys.argv[1:]:
|
176
|
17 print findInPath(i)
|