176
|
1 #!/usr/bin/env python
|
|
2
|
|
3 import os
|
|
4 import sys
|
|
5
|
218
|
6 def which(fileName, path=os.environ['PATH']):
|
170
|
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:]:
|
218
|
17 print which(i)
|