| Index: third_party/coverage-3.7.1/coverage/html.py
|
| diff --git a/third_party/coverage-3.6/coverage/html.py b/third_party/coverage-3.7.1/coverage/html.py
|
| similarity index 83%
|
| rename from third_party/coverage-3.6/coverage/html.py
|
| rename to third_party/coverage-3.7.1/coverage/html.py
|
| index ed8920f21e8a208dc1f8c53e8d27279c5e06d372..5242236c1ed9826d19f7abe1a7c4499dc90414dd 100644
|
| --- a/third_party/coverage-3.6/coverage/html.py
|
| +++ b/third_party/coverage-3.7.1/coverage/html.py
|
| @@ -10,13 +10,36 @@ from coverage.report import Reporter
|
| from coverage.results import Numbers
|
| from coverage.templite import Templite
|
|
|
| -# Disable pylint msg W0612, because a bunch of variables look unused, but
|
| -# they're accessed in a Templite context via locals().
|
| -# pylint: disable=W0612
|
|
|
| -def data_filename(fname):
|
| - """Return the path to a data file of ours."""
|
| - return os.path.join(os.path.split(__file__)[0], fname)
|
| +# Static files are looked for in a list of places.
|
| +STATIC_PATH = [
|
| + # The place Debian puts system Javascript libraries.
|
| + "/usr/share/javascript",
|
| +
|
| + # Our htmlfiles directory.
|
| + os.path.join(os.path.dirname(__file__), "htmlfiles"),
|
| +]
|
| +
|
| +def data_filename(fname, pkgdir=""):
|
| + """Return the path to a data file of ours.
|
| +
|
| + The file is searched for on `STATIC_PATH`, and the first place it's found,
|
| + is returned.
|
| +
|
| + Each directory in `STATIC_PATH` is searched as-is, and also, if `pkgdir`
|
| + is provided, at that subdirectory.
|
| +
|
| + """
|
| + for static_dir in STATIC_PATH:
|
| + static_filename = os.path.join(static_dir, fname)
|
| + if os.path.exists(static_filename):
|
| + return static_filename
|
| + if pkgdir:
|
| + static_filename = os.path.join(static_dir, pkgdir, fname)
|
| + if os.path.exists(static_filename):
|
| + return static_filename
|
| + raise CoverageException("Couldn't find static file %r" % fname)
|
| +
|
|
|
| def data(fname):
|
| """Return the contents of a data file of ours."""
|
| @@ -32,14 +55,14 @@ class HtmlReporter(Reporter):
|
|
|
| # These files will be copied from the htmlfiles dir to the output dir.
|
| STATIC_FILES = [
|
| - "style.css",
|
| - "jquery-1.4.3.min.js",
|
| - "jquery.hotkeys.js",
|
| - "jquery.isonscreen.js",
|
| - "jquery.tablesorter.min.js",
|
| - "coverage_html.js",
|
| - "keybd_closed.png",
|
| - "keybd_open.png",
|
| + ("style.css", ""),
|
| + ("jquery.min.js", "jquery"),
|
| + ("jquery.hotkeys.js", "jquery-hotkeys"),
|
| + ("jquery.isonscreen.js", "jquery-isonscreen"),
|
| + ("jquery.tablesorter.min.js", "jquery-tablesorter"),
|
| + ("coverage_html.js", ""),
|
| + ("keybd_closed.png", ""),
|
| + ("keybd_open.png", ""),
|
| ]
|
|
|
| def __init__(self, cov, config):
|
| @@ -52,7 +75,7 @@ class HtmlReporter(Reporter):
|
| '__version__': coverage.__version__,
|
| }
|
| self.source_tmpl = Templite(
|
| - data("htmlfiles/pyfile.html"), self.template_globals
|
| + data("pyfile.html"), self.template_globals
|
| )
|
|
|
| self.coverage = cov
|
| @@ -102,9 +125,9 @@ class HtmlReporter(Reporter):
|
| def make_local_static_report_files(self):
|
| """Make local instances of static files for HTML report."""
|
| # The files we provide must always be copied.
|
| - for static in self.STATIC_FILES:
|
| + for static, pkgdir in self.STATIC_FILES:
|
| shutil.copyfile(
|
| - data_filename("htmlfiles/" + static),
|
| + data_filename(static, pkgdir),
|
| os.path.join(self.directory, static)
|
| )
|
|
|
| @@ -161,8 +184,8 @@ class HtmlReporter(Reporter):
|
| # Get the numbers for this file.
|
| nums = analysis.numbers
|
|
|
| - missing_branch_arcs = analysis.missing_branch_arcs()
|
| - arcs = self.arcs
|
| + if self.arcs:
|
| + missing_branch_arcs = analysis.missing_branch_arcs()
|
|
|
| # These classes determine which lines are highlighted by default.
|
| c_run = "run hide_run"
|
| @@ -220,13 +243,17 @@ class HtmlReporter(Reporter):
|
| })
|
|
|
| # Write the HTML page for this file.
|
| - html_filename = flat_rootname + ".html"
|
| - html_path = os.path.join(self.directory, html_filename)
|
| - extra_css = self.extra_css
|
| + html = spaceless(self.source_tmpl.render({
|
| + 'c_exc': c_exc, 'c_mis': c_mis, 'c_par': c_par, 'c_run': c_run,
|
| + 'arcs': self.arcs, 'extra_css': self.extra_css,
|
| + 'cu': cu, 'nums': nums, 'lines': lines,
|
| + }))
|
|
|
| - html = spaceless(self.source_tmpl.render(locals()))
|
| if sys.version_info < (3, 0):
|
| html = html.decode(encoding)
|
| +
|
| + html_filename = flat_rootname + ".html"
|
| + html_path = os.path.join(self.directory, html_filename)
|
| self.write_html(html_path, html)
|
|
|
| # Save this file's information for the index file.
|
| @@ -241,16 +268,18 @@ class HtmlReporter(Reporter):
|
| def index_file(self):
|
| """Write the index.html file for this report."""
|
| index_tmpl = Templite(
|
| - data("htmlfiles/index.html"), self.template_globals
|
| + data("index.html"), self.template_globals
|
| )
|
|
|
| - files = self.files
|
| - arcs = self.arcs
|
| + self.totals = sum([f['nums'] for f in self.files])
|
|
|
| - self.totals = totals = sum([f['nums'] for f in files])
|
| - extra_css = self.extra_css
|
| + html = index_tmpl.render({
|
| + 'arcs': self.arcs,
|
| + 'extra_css': self.extra_css,
|
| + 'files': self.files,
|
| + 'totals': self.totals,
|
| + })
|
|
|
| - html = index_tmpl.render(locals())
|
| if sys.version_info < (3, 0):
|
| html = html.decode("utf-8")
|
| self.write_html(
|
|
|