Mercurial > cpython-lru_cache-weakref
view Mac/scripts/zappycfiles.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | f6785bce54b5 |
| children |
line wrap: on
line source
#!/usr/bin/env python """Recursively zap all .pyc and .pyo files""" import os import sys # set doit true to actually delete files # set doit false to just print what would be deleted doit = 1 def main(): if not sys.argv[1:]: print 'Usage: zappyc dir ...' sys.exit(1) for dir in sys.argv[1:]: zappyc(dir) def zappyc(dir): os.path.walk(dir, walker, None) def walker(dummy, top, names): for name in names: if name[-4:] in ('.pyc', '.pyo'): path = os.path.join(top, name) print 'Zapping', path if doit: os.unlink(path) if __name__ == '__main__': main()
