blob: dbe95b674ac56d9418a5a342ea3b0eef943c9d4d [file] [log] [blame]
Jack Jansendfebb272001-01-23 22:45:52 +00001# Zap .pyc files
2import os
3import sys
4
5doit = 1
6
7def main():
8 if os.name == 'mac':
9 import macfs
10 fss, ok = macfs.GetDirectory('Directory to zap pyc files in')
11 if not ok:
12 sys.exit(0)
13 dir = fss.as_pathname()
14 zappyc(dir)
15 else:
16 if not sys.argv[1:]:
17 print 'Usage: zappyc dir ...'
18 sys.exit(1)
19 for dir in sys.argv[1:]:
20 zappyc(dir)
21
22def zappyc(dir):
23 os.path.walk(dir, walker, None)
24
25def walker(dummy, top, names):
26 for name in names:
27 if name[-4:] == '.pyc':
28 path = os.path.join(top, name)
29 print 'Zapping', path
30 if doit:
31 os.unlink(path)
32
33if __name__ == '__main__':
34 main()
35