forked from eliben/pycparser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_clean_tables.py
More file actions
24 lines (19 loc) · 736 Bytes
/
_clean_tables.py
File metadata and controls
24 lines (19 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Cleanup all tables and PYC files to ensure no PLY stuff is cached
from __future__ import print_function
import itertools
import fnmatch
import os, shutil
file_patterns = ('yacctab.*', 'lextab.*', '*.pyc', '__pycache__')
def do_cleanup(root):
for path, dirs, files in os.walk(root):
for file in itertools.chain(dirs, files):
try:
for pattern in file_patterns:
if fnmatch.fnmatch(file, pattern):
fullpath = os.path.join(path, file)
shutil.rmtree(fullpath, ignore_errors=True)
print('Deleted', fullpath)
except OSError:
pass
if __name__ == "__main__":
do_cleanup('.')