|
- #!/usr/bin/env python
-
- import os
- import re
-
- __author__ = "Nate Bohman"
- __credits__ = ["Nate Bohman"]
- __license__ = "LGPL-3"
- __maintainer__ = "Nate Bohman"
- __email__ = "natrinicle@natrinicle.com"
- __status__ = "Production"
-
- COVERAGE_PATH = os.path.abspath(os.path.dirname(__file__))
- source_regex = re.compile(r"<div id=\"source.*?</div>", re.DOTALL)
-
- for filename in os.listdir(COVERAGE_PATH):
- if filename.endswith("_py.html"):
- # Cut off .html and add .source.html
- source_only_filename = "{}.source.html".format(filename[:-5])
- with open(os.path.join(COVERAGE_PATH, filename), "r") as file:
- contents = file.read()
- source_div = source_regex.search(contents)
- if source_div is not None:
- with open(
- os.path.join(COVERAGE_PATH, source_only_filename), "w"
- ) as output_file:
- for line in source_div.group().split("\n"):
- output_file.write("{}\n".format(line))
|