From 34f71934dacede93f59b372fde4c5a646dbc702b Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 7 Feb 2010 16:37:14 -0500 Subject: Clean up the lst += string stuff, whereby string being iterable means each char is added as an element of the list. Also, apply the 'join is better than append' rule to other places, where, alas, it doesn't seem to have the same magic effect. --- coverage/html.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'coverage/html.py') diff --git a/coverage/html.py b/coverage/html.py index 4d51eb3..39ee886 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -69,27 +69,27 @@ class HtmlReporter(Reporter): arcs = self.arcs # These classes determine which lines are highlighted by default. - c_run = " run hide_run" - c_exc = " exc" - c_mis = " mis" - c_par = " par" + c_run + c_run = "run hide_run" + c_exc = "exc" + c_mis = "mis" + c_par = "par " + c_run lines = [] for lineno, line in enumerate(source_token_lines(source)): lineno += 1 # 1-based line numbers. # Figure out how to mark this line. - line_class = "" + line_class = [] annotate_html = "" annotate_title = "" if lineno in analysis.statements: - line_class += " stm" + line_class.append("stm") if lineno in analysis.excluded: - line_class += c_exc + line_class.append(c_exc) elif lineno in analysis.missing: - line_class += c_mis + line_class.append(c_mis) elif self.arcs and lineno in missing_branch_arcs: - line_class += c_par + line_class.append(c_par) n_par += 1 annlines = [] for b in missing_branch_arcs[lineno]: @@ -103,21 +103,21 @@ class HtmlReporter(Reporter): elif len(annlines) == 1: annotate_title = "no jump to this line number" elif lineno in analysis.statements: - line_class += c_run + line_class.append(c_run) # Build the HTML for the line - html = "" + html = [] for tok_type, tok_text in line: if tok_type == "ws": - html += escape(tok_text) + html.append(escape(tok_text)) else: tok_html = escape(tok_text) or ' ' - html += "%s" % (tok_type, tok_html) + html.append("%s" % (tok_type, tok_html)) lines.append({ - 'html': html, + 'html': ''.join(html), 'number': lineno, - 'class': line_class.strip() or "pln", + 'class': ' '.join(line_class) or "pln", 'annotate': annotate_html, 'annotate_title': annotate_title, }) -- cgit v1.2.1 From 4421797d3dddd1a9616c8164cc611aa998d385c3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 20 Feb 2010 08:48:01 -0500 Subject: Lint cleanups --- coverage/html.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'coverage/html.py') diff --git a/coverage/html.py b/coverage/html.py index 39ee886..f8de2e4 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -112,7 +112,9 @@ class HtmlReporter(Reporter): html.append(escape(tok_text)) else: tok_html = escape(tok_text) or ' ' - html.append("%s" % (tok_type, tok_html)) + html.append( + "%s" % (tok_type, tok_html) + ) lines.append({ 'html': ''.join(html), -- cgit v1.2.1