blob: ab7cfcbfbca7f5bc9c9c1e9d0526175c214c3cbc [file] [log] [blame]
Eli Benderskye936d412015-04-20 15:53:11 -07001# Cleanup all tables and PYC files to ensure no PLY stuff is cached
2from __future__ import print_function
3import fnmatch
4import os, shutil
5
6file_patterns = ('yacctab.*', 'lextab.*', '*.pyc', '__pycache__')
7
8
9def do_cleanup(root):
10 for path, dirs, files in os.walk(root):
11 for file in files:
12 try:
13 for pattern in file_patterns:
14 if fnmatch.fnmatch(file, pattern):
15 fullpath = os.path.join(path, file)
16 os.remove(fullpath)
17 print('Deleted', fullpath)
18 except OSError:
19 pass
20
21
22if __name__ == "__main__":
23 do_cleanup('.')