Staging
v0.5.1
https://github.com/python/cpython
Revision 427f6ca969cbc0cb506af69e38da34f25da858a8 authored by Anthony Baxter on 01 November 2006, 07:07:27 UTC, committed by Anthony Baxter on 01 November 2006, 07:07:27 UTC
1 parent 5c099d7
Raw File
Tip revision: 427f6ca969cbc0cb506af69e38da34f25da858a8 authored by Anthony Baxter on 01 November 2006, 07:07:27 UTC
update patchlevel.h correctly, this time
Tip revision: 427f6ca
zappycfiles.py
#!/usr/local/bin/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:]:
		if os.name == 'mac':
			import EasyDialogs
			dir = EasyDialogs.AskFolder(message='Directory to zap pyc files in')
			if not dir:
				sys.exit(0)
			zappyc(dir)
		else:
			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()
	
back to top