diff options
author | Eli Bendersky <eliben@google.com> | 2015-04-20 15:53:11 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@google.com> | 2015-04-20 15:53:11 -0700 |
commit | e936d41acf13ae8995c3cdef01ca641917ef2db4 (patch) | |
tree | 42bb7f4b3e6dc062b2f19767d8f2002580fcdefa /_clean_tables.py | |
parent | 3c0c601d9239793d89194391b1d52a0f9013516c (diff) | |
download | pycparser-e936d41acf13ae8995c3cdef01ca641917ef2db4.tar.gz |
Clean-up _clean_tables and make it Python3-friendly
Diffstat (limited to '_clean_tables.py')
-rw-r--r-- | _clean_tables.py | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/_clean_tables.py b/_clean_tables.py index 48417b0..ab7cfcb 100644 --- a/_clean_tables.py +++ b/_clean_tables.py @@ -1,24 +1,23 @@ -# Cleanup all table and PYC files to ensure no PLY stuff is cached
-#
-import fnmatch
-import os, shutil
-
-file_patterns = ('yacctab.*', 'lextab.*', '*.pyc')
-
-def do_cleanup(root):
- for path, dirs, files in os.walk(root):
- for file in files:
- try:
- for pattern in file_patterns:
- if fnmatch.fnmatch(file, pattern):
- fullpath = os.path.join(path, file)
- os.remove(fullpath)
- print 'Deleted', fullpath
- except OSError:
- pass
-
-if __name__ == "__main__":
- do_cleanup('.')
-
-
-
\ No newline at end of file +# Cleanup all tables and PYC files to ensure no PLY stuff is cached +from __future__ import print_function +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 files: + try: + for pattern in file_patterns: + if fnmatch.fnmatch(file, pattern): + fullpath = os.path.join(path, file) + os.remove(fullpath) + print('Deleted', fullpath) + except OSError: + pass + + +if __name__ == "__main__": + do_cleanup('.') |