2006-05-27 22:52:38 -03:00
|
|
|
# Remove all the .pyc and .pyo files under ../Lib.
|
2007-05-02 12:55:14 -03:00
|
|
|
import sys
|
2006-05-27 22:52:38 -03:00
|
|
|
|
|
|
|
|
|
|
|
def deltree(root):
|
|
|
|
import os
|
|
|
|
from os.path import join
|
|
|
|
|
|
|
|
npyc = npyo = 0
|
|
|
|
for root, dirs, files in os.walk(root):
|
|
|
|
for name in files:
|
|
|
|
delete = False
|
|
|
|
if name.endswith('.pyc'):
|
|
|
|
delete = True
|
|
|
|
npyc += 1
|
|
|
|
elif name.endswith('.pyo'):
|
|
|
|
delete = True
|
|
|
|
npyo += 1
|
|
|
|
|
|
|
|
if delete:
|
|
|
|
os.remove(join(root, name))
|
|
|
|
|
|
|
|
return npyc, npyo
|
|
|
|
|
2007-05-02 12:55:14 -03:00
|
|
|
path = "../Lib"
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
path = sys.argv[1]
|
|
|
|
|
|
|
|
npyc, npyo = deltree(path)
|
2006-05-27 22:52:38 -03:00
|
|
|
print npyc, ".pyc deleted,", npyo, ".pyo deleted"
|