Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # Search for files upward from current working directory
- import os
- import stat
- import sys
- def upfind(file):
- dir = os.getcwd()
- fullpath = os.path.join(dir, file)
- while not os.path.isfile(fullpath):
- if dir == "/":
- break
- dir = os.path.dirname(dir)
- fullpath = os.path.join(dir, file)
- return fullpath if os.path.isfile(fullpath) else None
- if __name__ == "__main__":
- for path in filter(None, [upfind(arg) for arg in sys.argv[1:]]):
- print path
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement