From b7dc63cbe56ceded8b36385c2af605ad71f76539 Mon Sep 17 00:00:00 2001 From: Eva Schiffer <evas@ssec.wisc.edu> Date: Mon, 8 Nov 2021 11:31:45 -0600 Subject: [PATCH] belt and suspenders our zebra tables because mako doesn't believe in belts --- pyglance/glance/report-base.txt | 66 +++++++++++++--------- pyglance/glance/report-variable.txt | 88 +++++++++++++++++++---------- 2 files changed, 97 insertions(+), 57 deletions(-) diff --git a/pyglance/glance/report-base.txt b/pyglance/glance/report-base.txt index 6508d87..6d822bf 100644 --- a/pyglance/glance/report-base.txt +++ b/pyglance/glance/report-base.txt @@ -16,31 +16,33 @@ Copyright (c) 2011 University of Wisconsin SSEC. All rights reserved. <%block name="cssStyle"> <style> - th.l { text-align: left; } - td.n,th.n { text-align: right; } - body { font-family: sans-serif; } - h4 { margin-bottom: 0; } - tr th { background-color: white; } - tr:nth-child(even) { background-color: #EEE; } - table { border-collapse: collapse; } - td, th { padding-left: 0.5em; padding-right: 0.5em; } - .testfail,.testpass { - display: inline-block; - border: 4px solid black; - text-align: center; - width: 1.15em; - max-width: 1.15em; - height: 1.15em; - max-height: 1.15em; - font-size: 3em; - font-weight: bold; - } - .testfail { - color: #F00; - } - .testpass { - color: #0F0; - } + th.l { text-align: left; } + td.n,th.n { text-align: right; } + body { font-family: sans-serif; } + h4 { margin-bottom: 0; } + tr th { background-color: white; } + tr:nth-child(even) { background-color: #EEE; } + ## the tr.evenrow is for coping with PyQt not letting us use nth-child + tr.evenrow { background-color: #EEE; } + table { border-collapse: collapse; } + td, th { padding-left: 0.5em; padding-right: 0.5em; } + .testfail,.testpass { + display: inline-block; + border: 4px solid black; + text-align: center; + width: 1.15em; + max-width: 1.15em; + height: 1.15em; + max-height: 1.15em; + font-size: 3em; + font-weight: bold; + } + .testfail { + color: #F00; + } + .testpass { + color: #0F0; + } </style> </%block> @@ -212,8 +214,20 @@ Copyright (c) 2011 University of Wisconsin SSEC. All rights reserved. % endfor </tr> ## loop to put a line in the table for each attribute + <% + # this is coping with the PyQt gui not handling nth-child + # we're starting with true because we have one table headder row + isEven = True + %> % for attrKey in sorted(allAttrKeys) : - <tr> + % if isEven : + <tr class="evenrow"> + % else : + <tr> + % endif + <% + isEven = not isEven + %> <td>${attrKey}</td> ## loop to add values for each of the files % for fileKey in sorted(attributesInfo) : diff --git a/pyglance/glance/report-variable.txt b/pyglance/glance/report-variable.txt index 0f56145..7cc2d37 100644 --- a/pyglance/glance/report-variable.txt +++ b/pyglance/glance/report-variable.txt @@ -117,39 +117,65 @@ Copyright (c) 2011 University of Wisconsin SSEC. All rights reserved. ## list out all of the statistics groups we have <%def name="doclink()"> - % if constants.DOCUMENTATION_PATH_KEY in runInfo: - <a href="${runInfo[constants.DOCUMENTATION_PATH_KEY]}">*</a> - % else: - % endif + % if constants.DOCUMENTATION_PATH_KEY in runInfo: + <a href="${runInfo[constants.DOCUMENTATION_PATH_KEY]}">*</a> + % else: + % endif </%def> - <table> - % if groupedStats is UNDEFINED: - % for setName in sorted(list(statGroups)) : - <% dataSet = statGroups[setName] %> - <tr><th class="l" colspan="2">${setName}</th></tr> - % for statName, statValue in sorted(list(dataSet.items())) : - <tr> - <td class="n">${statName}${doclink()}:</td> - <td class="n">${report.make_formatted_display_string(statValue)}</td> - </tr> - % endfor - % endfor - % else: - % for setName in sorted(list(groupedStats)) : - <% dataSet = groupedStats[setName] %> - <tr><th class="l">${setName}</th><th>Both</th><th>File A</th><th>File B</th></tr> - % for statName, statValue in sorted(list(dataSet.items())) : - <tr> - <td class="n">${statName}${doclink()}:</td> - <td class="n">${report.make_formatted_display_string(statValue['both'])}</td> - <td class="n">${report.make_formatted_display_string(statValue['a'])}</td> - <td class="n">${report.make_formatted_display_string(statValue['b'])}</td> - </tr> - % endfor - % endfor - % endif - </table> + <table> + <% + # this is coping with the PyQt gui not handling nth-child + isEven = False + %> + % if groupedStats is UNDEFINED: + % for setName in sorted(list(statGroups)) : + <% dataSet = statGroups[setName] %> + <tr><th class="l" colspan="2">${setName}</th></tr> + <% + # to make our two ways of striping agree, turn this on and off for header rows too + isEven = not isEven + %> + % for statName, statValue in sorted(list(dataSet.items())) : + % if isEven : + <tr class="evenrow"> + % else : + <tr> + % endif + <% + isEven = not isEven + %> + <td class="n">${statName}${doclink()}:</td> + <td class="n">${report.make_formatted_display_string(statValue)}</td> + </tr> + % endfor + % endfor + % else: + % for setName in sorted(list(groupedStats)) : + <% dataSet = groupedStats[setName] %> + <tr><th class="l">${setName}</th><th>Both</th><th>File A</th><th>File B</th></tr> + <% + # to make our two ways of striping agree, turn this on and off for header rows too + isEven = not isEven + %> + % for statName, statValue in sorted(list(dataSet.items())) : + % if isEven : + <tr class="evenrow"> + % else : + <tr> + % endif + <% + isEven = not isEven + %> + <td class="n">${statName}${doclink()}:</td> + <td class="n">${report.make_formatted_display_string(statValue['both'])}</td> + <td class="n">${report.make_formatted_display_string(statValue['a'])}</td> + <td class="n">${report.make_formatted_display_string(statValue['b'])}</td> + </tr> + % endfor + % endfor + % endif + </table> </%block> -- GitLab