source: python/vendor/Python-2.7.6/Mac/scripts/zappycfiles.py

Last change on this file was 388, checked in by dmik, 11 years ago

python: Update vendor to 2.7.6.

  • Property svn:eol-style set to native
File size: 658 bytes
Line 
1#!/usr/bin/env 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 print 'Usage: zappyc dir ...'
13 sys.exit(1)
14 for dir in sys.argv[1:]:
15 zappyc(dir)
16
17def zappyc(dir):
18 os.path.walk(dir, walker, None)
19
20def walker(dummy, top, names):
21 for name in names:
22 if name[-4:] in ('.pyc', '.pyo'):
23 path = os.path.join(top, name)
24 print 'Zapping', path
25 if doit:
26 os.unlink(path)
27
28if __name__ == '__main__':
29 main()
Note: See TracBrowser for help on using the repository browser.