eli.bendersky | 49f3b63 | 2011-10-31 06:38:41 +0200 | [diff] [blame] | 1 | # Cleanup all table and PYC files to ensure no PLY stuff is cached
|
| 2 | #
|
| 3 | import fnmatch
|
| 4 | import os, shutil
|
| 5 |
|
| 6 | file_patterns = ('yacctab.*', 'lextab.*', '*.pyc')
|
| 7 |
|
| 8 | def do_cleanup(root):
|
| 9 | for path, dirs, files in os.walk(root):
|
| 10 | for file in files:
|
| 11 | try:
|
| 12 | for pattern in file_patterns:
|
| 13 | if fnmatch.fnmatch(file, pattern):
|
| 14 | fullpath = os.path.join(path, file)
|
| 15 | os.remove(fullpath)
|
| 16 | print 'Deleted', fullpath
|
| 17 | except OSError:
|
| 18 | pass
|
| 19 |
|
| 20 | if __name__ == "__main__":
|
| 21 | do_cleanup('.')
|
| 22 |
|
| 23 |
|
| 24 | |