Generate a Python package project using the Python Cookiecutter package
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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