/Tools/scripts/lll.py

http://unladen-swallow.googlecode.com/ · Python · 28 lines · 19 code · 4 blank · 5 comment · 8 complexity · b2a3f8cab727ec49ccc40c1556bc96f9 MD5 · raw file

  1. #! /usr/bin/env python
  2. # Find symbolic links and show where they point to.
  3. # Arguments are directories to search; default is current directory.
  4. # No recursion.
  5. # (This is a totally different program from "findsymlinks.py"!)
  6. import sys, os
  7. def lll(dirname):
  8. for name in os.listdir(dirname):
  9. if name not in (os.curdir, os.pardir):
  10. full = os.path.join(dirname, name)
  11. if os.path.islink(full):
  12. print name, '->', os.readlink(full)
  13. def main():
  14. args = sys.argv[1:]
  15. if not args: args = [os.curdir]
  16. first = 1
  17. for arg in args:
  18. if len(args) > 1:
  19. if not first: print
  20. first = 0
  21. print arg + ':'
  22. lll(arg)
  23. if __name__ == '__main__':
  24. main()