diff options
author | Eli Bendersky <eliben@gmail.com> | 2015-05-10 15:25:10 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2015-05-10 15:25:10 -0700 |
commit | e460ca8e7bb5da9f5242392606afb3fe45c5ab2d (patch) | |
tree | 5c3746561a9a1fccbfe806462eff93b72957396b /_clean_tables.py | |
parent | 779f46f7d49367273a12246790c5796659c4130c (diff) | |
download | pycparser-e460ca8e7bb5da9f5242392606afb3fe45c5ab2d.tar.gz |
Tweak cleanup script to kill __pycache__ dirs as well.
Diffstat (limited to '_clean_tables.py')
-rw-r--r-- | _clean_tables.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/_clean_tables.py b/_clean_tables.py index ab7cfcb..155a820 100644 --- a/_clean_tables.py +++ b/_clean_tables.py @@ -1,5 +1,6 @@ # 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 @@ -8,12 +9,12 @@ file_patterns = ('yacctab.*', 'lextab.*', '*.pyc', '__pycache__') def do_cleanup(root): for path, dirs, files in os.walk(root): - for file in files: + for file in itertools.chain(dirs, files): try: for pattern in file_patterns: if fnmatch.fnmatch(file, pattern): fullpath = os.path.join(path, file) - os.remove(fullpath) + shutil.rmtree(fullpath, ignore_errors=True) print('Deleted', fullpath) except OSError: pass |