historical/toontown-classic.git/tools/cleanup.py
2024-01-16 11:20:27 -06:00

32 lines
757 B
Python

# Cleanse the "../" directory of the following:
# - all files with a PYC or PYO extension.
# - all "trash files" listed below:
# . parsetab.py - generated by the ply library.
import os
extensions = ('.pyc', '.pyo')
trashFiles = ('parsetab.py',)
print 'Changing to root directory...'
os.chdir('../')
print 'Scanning for garbage files...'
def delete(filepath):
print "Removing '{0}'...".format(filepath)
os.unlink(filepath)
for root, folders, files in os.walk('.'):
for filename in files:
filepath = os.path.join(root, filename)
if os.path.splitext(filename)[1] in extensions:
delete(filepath)
elif filename in trashFiles:
delete(filepath)
print 'Done.'
os.system('pause')