STDOUT_REPORT_CATEGORY = " {name:.<19}: {percent:5.1f}% covered ({covered} of {total})\n"
-HTML_SUMMARY_ROW = """
+HTML_SUMMARY_ROW = '''
<tr>
<td class="headerItem"><a href="#{name}">{name}:</a></td>
<td class="headerCovTableEntry">{total}</td>
<td class="headerCovTableEntry">{covered}</td>
<td class="headerCovTableEntry">{percent:.1f}%</td>
</tr>
-"""
+'''
-HTML_CATEGORY_SECTION = """
+HTML_CATEGORY_SECTION = '''
<tr id="{id}"></tr>
{rows}
<tr>
<td> </td>
</tr>
-"""
+'''
-HTML_CATEGORY_HEADER = """
+HTML_CATEGORY_HEADER = '''
<tr>
<td class="tableHead" width="60%" colspan="{colspan}">{label}</td>
{cells}
</tr>
-"""
+'''
HTML_CATEGORY_HEADER_CELL = '<td class="tableHead" width="15%">{}</td>\n'
HTML_CATEGORY_COVERAGE_CELL = '<td class="{}"> </td>\n'
-HTML_CATEGORY_ROW = """
+HTML_CATEGORY_ROW = '''
<tr>
<td class="coverFile" colspan="{colspan}">{id}</td>
{cells}
</tr>
-"""
+'''
def search(needle, haystack):
# Search for needle in haystack, first escaping needle for regex, then
category["percent"] = (category["covered"] / float(category["total"])) * 100
# render section header
- cat_keys = list(category["messages"].items())[0][1].keys()
+ cat_messages = sorted(category["messages"].items())
+ cat_keys = cat_messages[0][1].keys()
headers_html = ""
colspan = 10 - len(cat_keys)
for key in cat_keys:
category_html = HTML_CATEGORY_HEADER.format(colspan=colspan, label=category["name"], cells=headers_html)
# render message coverage row
- for message_id, covered in sorted(category["messages"].items()):
+ for message_id, covered in cat_messages:
category_html_row = ""
for key, value in covered.items():
category_html_row += HTML_CATEGORY_COVERAGE_CELL.format("uncovered" if value != True else "covered")