Tools to remove stale pyc files

This commit is contained in:
Laurent Bachelier 2013-04-09 23:00:28 +02:00 committed by Romain Bignon
commit 133c83ed8e

13
tools/stale_pyc.py Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env python
import os
import sys
root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
verbose = '-v' in sys.argv
for dirpath, dirnames, filenames in os.walk(root):
for filename in filenames:
if filename.endswith('.pyc') or filename.endswith('pyo'):
if not os.path.exists(os.path.join(dirpath, filename[:-1])):
os.unlink(os.path.join(dirpath, filename))
if verbose:
print os.path.join(dirpath, filename)