annotate python/which.py @ 171:0110a435d2ce

use a directory for mozconfigs
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 13 Oct 2011 12:13:31 -0700
parents 3e52d6bcac99
children b91750a108b2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
170
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 def findInPath(fileName, path=os.environ['PATH']):
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 """python equivalent of which; should really be in the stdlib"""
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 dirs = path.split(os.pathsep)
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 for dir in dirs:
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 if os.path.isfile(os.path.join(dir, fileName)):
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 return os.path.join(dir, fileName)
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 if mozinfo.isWin:
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 if os.path.isfile(os.path.join(dir, fileName + ".exe")):
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 return os.path.join(dir, fileName + ".exe")
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 if __name__ == '__main__':
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 for i in sys.argv[1:]:
3e52d6bcac99 add the which thingy
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 print findInPath(i)