0
|
1 #!/usr/bin/env python
|
|
2
|
|
3 import os
|
|
4 import sys
|
|
5
|
|
6 def which(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)
|
|
12 if os.path.isfile(os.path.join(dir, fileName + ".exe")):
|
|
13 return os.path.join(dir, fileName + ".exe")
|
|
14
|
|
15 def main(args=sys.argv[1:]):
|
|
16 """CLI"""
|
|
17 for i in sys.argv[1:]:
|
|
18 print which(i)
|
|
19
|
|
20 if __name__ == '__main__':
|
|
21 main()
|