Generate a Python package project using the Python Cookiecutter package
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1004B

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import os
  4. import re
  5. __author__ = "Nate Bohman"
  6. __credits__ = ["Nate Bohman"]
  7. __license__ = "LGPL-3"
  8. __maintainer__ = "Nate Bohman"
  9. __email__ = "natrinicle@natrinicle.com"
  10. __status__ = "Production"
  11. COVERAGE_PATH = os.path.abspath(os.path.dirname(__file__))
  12. source_regex = re.compile(r"<div id=\"source.*?</div>", re.DOTALL)
  13. for filename in os.listdir(COVERAGE_PATH):
  14. if filename.endswith("_py.html"):
  15. # Cut off .html and add .source.html
  16. source_only_filename = "{}.source.html".format(filename[:-5])
  17. with open(os.path.join(COVERAGE_PATH, filename), "r") as file:
  18. contents = file.read()
  19. source_div = source_regex.search(contents)
  20. if source_div is not None:
  21. with open(
  22. os.path.join(COVERAGE_PATH, source_only_filename), "w"
  23. ) as output_file:
  24. for line in source_div.group().split("\n"):
  25. output_file.write("{}\n".format(line))