diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2019-06-17 17:25:23 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-06-17 18:33:58 -0400 |
commit | 014786bd145127765397f752dab0ff2307b9c147 (patch) | |
tree | 7ca9deead369acb31431a4e8c96346079cbc4c85 /coverage/html.py | |
parent | 1ae442ac70efa74d50a98568d7d7e01b3b7792b8 (diff) | |
download | python-coveragepy-git-014786bd145127765397f752dab0ff2307b9c147.tar.gz |
Move more into the template globals
Diffstat (limited to 'coverage/html.py')
-rw-r--r-- | coverage/html.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/coverage/html.py b/coverage/html.py index 1ae2c94b..6b3c272a 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -110,15 +110,30 @@ class HtmlReporter(object): else: self.extra_css = None + self.data = self.coverage.get_data() + self.has_arcs = self.data.has_arcs() + + self.files = [] + self.all_files_nums = [] + self.incr = IncrementalChecker(self.directory) + self.totals = Numbers() + self.template_globals = { + # Functions available in the templates. 'escape': escape, 'pair': pair, 'title': title, 'len': len, + + # Constants for this report. '__url__': coverage.__url__, '__version__': coverage.__version__, 'time_stamp': datetime.datetime.now().strftime('%Y-%m-%d %H:%M'), 'extra_css': self.extra_css, + 'has_arcs': self.has_arcs, + 'show_contexts': self.config.show_contexts, + + # Constants for all reports. 'c_exc': self.c_exc, 'c_mis': self.c_mis, 'c_par': self.c_par, @@ -127,14 +142,6 @@ class HtmlReporter(object): self.pyfile_html_source = read_data("pyfile.html") self.source_tmpl = Templite(self.pyfile_html_source, self.template_globals) - self.data = self.coverage.get_data() - - self.files = [] - self.all_files_nums = [] - self.has_arcs = self.data.has_arcs() - self.incr = IncrementalChecker(self.directory) - self.totals = Numbers() - def report(self, morfs): """Generate an HTML report for `morfs`. @@ -305,8 +312,6 @@ class HtmlReporter(object): }) file_data = { - 'has_arcs': self.has_arcs, - 'show_contexts': self.config.show_contexts, 'relative_filename': fr.relative_filename(), 'nums': analysis.numbers, 'lines': lines, @@ -321,7 +326,6 @@ class HtmlReporter(object): self.totals = sum(self.all_files_nums) html = index_tmpl.render({ - 'has_arcs': self.has_arcs, 'files': self.files, 'totals': self.totals, }) |