source: vendor/python/2.5/Mac/scripts/zappycfiles.py

Last change on this file was 3225, checked in by bird, 18 years ago

Python 2.5

File size: 899 bytes
Line 
1#!/usr/local/bin/python
2"""Recursively zap all .pyc and .pyo files"""
3import os
4import sys
5
6# set doit true to actually delete files
7# set doit false to just print what would be deleted
8doit = 1
9
10def main():
11 if not sys.argv[1:]:
12 if os.name == 'mac':
13 import EasyDialogs
14 dir = EasyDialogs.AskFolder(message='Directory to zap pyc files in')
15 if not dir:
16 sys.exit(0)
17 zappyc(dir)
18 else:
19 print 'Usage: zappyc dir ...'
20 sys.exit(1)
21 for dir in sys.argv[1:]:
22 zappyc(dir)
23
24def zappyc(dir):
25 os.path.walk(dir, walker, None)
26
27def walker(dummy, top, names):
28 for name in names:
29 if name[-4:] in ('.pyc', '.pyo'):
30 path = os.path.join(top, name)
31 print 'Zapping', path
32 if doit:
33 os.unlink(path)
34
35if __name__ == '__main__':
36 main()
Note: See TracBrowser for help on using the repository browser.