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