flush_compiler_caches.py 418 B

12345678910111213141516
  1. def flush(pattern):
  2. import os, re, os.path
  3. mypath = "."
  4. for root, dirs, files in os.walk(mypath):
  5. for file in filter(lambda x: re.match(pattern, x), files):
  6. print("Remove: %s" % os.path.join(root, file))
  7. os.remove(os.path.join(root, file))
  8. def flush_all():
  9. flush("^.*\.pickle$")
  10. flush("^.*\.pyc$")
  11. flush("^.*\.pyo$")
  12. if __name__ == "__main__":
  13. flush_all()