summaryrefslogtreecommitdiff
path: root/coverage/html.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-05-12 06:11:47 -0400
committerNed Batchelder <ned@nedbatchelder.com>2016-05-12 06:11:47 -0400
commit0a173117c3d9e98a3fcc9e5f79914b58ddc8ae65 (patch)
treee6dc01403394c89d118396510baf3bc2e1621d52 /coverage/html.py
parent8c48df1424272a5205a34d875738c7cc93d41e15 (diff)
downloadpython-coveragepy-0a173117c3d9e98a3fcc9e5f79914b58ddc8ae65.tar.gz
Move self-less methods to be functions.
Diffstat (limited to 'coverage/html.py')
-rw-r--r--coverage/html.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/coverage/html.py b/coverage/html.py
index 49eea96..e5b1db2 100644
--- a/coverage/html.py
+++ b/coverage/html.py
@@ -58,12 +58,18 @@ def data_filename(fname, pkgdir=""):
)
-def data(fname):
+def read_data(fname):
"""Return the contents of a data file of ours."""
with open(data_filename(fname)) as data_file:
return data_file.read()
+def write_html(fname, html):
+ """Write `html` to `fname`, properly encoded."""
+ with open(fname, "wb") as fout:
+ fout.write(html.encode('ascii', 'xmlcharrefreplace'))
+
+
class HtmlReporter(Reporter):
"""HTML reporting."""
@@ -94,9 +100,7 @@ class HtmlReporter(Reporter):
'__url__': coverage.__url__,
'__version__': coverage.__version__,
}
- self.source_tmpl = Templite(
- data("pyfile.html"), self.template_globals,
- )
+ self.source_tmpl = Templite(read_data("pyfile.html"), self.template_globals)
self.coverage = cov
@@ -158,11 +162,6 @@ class HtmlReporter(Reporter):
os.path.join(self.directory, self.extra_css)
)
- def write_html(self, fname, html):
- """Write `html` to `fname`, properly encoded."""
- with open(fname, "wb") as fout:
- fout.write(html.encode('ascii', 'xmlcharrefreplace'))
-
def file_hash(self, source, fr):
"""Compute a hash that changes if the file needs to be re-reported."""
m = Hasher()
@@ -272,7 +271,7 @@ class HtmlReporter(Reporter):
html_filename = rootname + ".html"
html_path = os.path.join(self.directory, html_filename)
- self.write_html(html_path, html)
+ write_html(html_path, html)
# Save this file's information for the index file.
index_info = {
@@ -285,7 +284,7 @@ class HtmlReporter(Reporter):
def index_file(self):
"""Write the index.html file for this report."""
- index_tmpl = Templite(data("index.html"), self.template_globals)
+ index_tmpl = Templite(read_data("index.html"), self.template_globals)
self.totals = sum(f['nums'] for f in self.files)
@@ -297,7 +296,7 @@ class HtmlReporter(Reporter):
'time_stamp': self.time_stamp,
})
- self.write_html(os.path.join(self.directory, "index.html"), html)
+ write_html(os.path.join(self.directory, "index.html"), html)
# Write the latest hashes for next time.
self.status.write(self.directory)