Just van Rossum | a840fca | 1999-09-26 12:25:06 +0000 | [diff] [blame] | 1 | import sys |
| 2 | import os |
| 3 | import macfs |
| 4 | |
| 5 | def walk(top): |
| 6 | names = os.listdir(top) |
| 7 | for name in names: |
| 8 | path = os.path.join(top, name) |
| 9 | if os.path.isdir(path): |
| 10 | walk(path) |
| 11 | else: |
| 12 | if path[-4:] in ['.pyc', '.pyo'] and os.path.exists(path[:-1]): |
| 13 | print "deleting:", path |
| 14 | os.remove(path) |
| 15 | elif path[-4:] == '.pyc': |
| 16 | print "!!! ------ .pyc file without .py file:", path |
| 17 | elif path[-4:] == '.pyo': |
| 18 | print "!!! ------ .pyo file without .py file:", path |
| 19 | |
| 20 | fss, ok = macfs.GetDirectory('Select the starting folder:') |
| 21 | if ok: |
| 22 | walk(fss.as_pathname()) |