Poodletooth-iLand/dev/tools/cleaner/cleanse.py

33 lines
746 B
Python
Raw Normal View History

2015-03-03 16:10:12 -06:00
#!/usr/bin/env python2
# Cleanse the "../" directory of the following:
# - all files with a .pyc extension.
# - all "trash files" listed below:
# . parsetab.py - generated by the PLY module.
import os
extensions = ('.pyc',)
trashFiles = ('parsetab.py',)
print 'Changing to root directory...'
2015-07-06 07:25:33 -05:00
os.chdir('../../../')
2015-03-03 16:10:12 -06:00
print 'Scanning for garbage files...'
def delete(filepath):
print "Removing '%s'..." % 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.'