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