clean_coverage.py 641 B

123456789101112131415161718192021222324
  1. """
  2. clean coverage
  3. """
  4. import os
  5. import shutil
  6. def delete_file(path):
  7. """delete file."""
  8. if not os.path.exists(path):
  9. if os.path.isfile(path):
  10. try:
  11. os.remove(path)
  12. print(f"File '{path}' deleted.")
  13. except TypeError as e:
  14. print(f"Error deleting file '{path}': {e}")
  15. elif os.path.isdir(path):
  16. try:
  17. shutil.rmtree(path)
  18. print(f"Directory '{path}' and its contents deleted.")
  19. except TypeError as e:
  20. print(f"Error deleting directory '{path}': {e}")
  21. if __name__ == "__main__":
  22. delete_file("htmlcov")