Skip to content

Commit a0ecf04

Browse files
authored
fix: correctly handle case when no same parts found. (#236)
1 parent 47b92dc commit a0ecf04

File tree

2 files changed

+45
-41
lines changed

2 files changed

+45
-41
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
UTIL_VERSION := 0.5.24
1+
UTIL_VERSION := 0.5.25
22
UTIL_NAME := codeplag
33
PWD := $(shell pwd)
44

src/templates/general.templ

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -117,27 +117,29 @@
117117
<th>{{ _("Similarity") }}, %</th>
118118
</tr>
119119
{% for first_head in same_parts_of_second %}
120-
{% set second_head = same_parts_of_second[first_head][0].name %}
121-
<tr class="table__row">
122-
<td rowspan="{{ len(same_parts_of_second[first_head]) }}">{{ first_head }}</td>
123-
<td>{{ second_head }}</td>
124-
{% set head_percent = same_parts_of_second[first_head].pop(0).percent %}
125-
{% if head_percent > threshold %}
126-
<td style="background-color: rgb(255, 200, 200); font-weight: bold;">{{ head_percent }}</td>
127-
{% else %}
128-
<td>{{ head_percent }}</td>
129-
{% endif %}
130-
</tr>
131-
{% for same_head_info in same_parts_of_second[first_head] %}
132-
<tr class="table__row">
133-
<td>{{ same_head_info.name }}</td>
134-
{% if same_head_info.percent > threshold %}
135-
<td style="background-color: rgb(255, 200, 200); font-weight: bold;">{{ same_head_info.percent }}</td>
136-
{% else %}
137-
<td>{{ same_head_info.percent }}</td>
120+
{% if same_parts_of_second[first_head] %}
121+
{% set second_head = same_parts_of_second[first_head][0].name %}
122+
<tr class="table__row">
123+
<td rowspan="{{ len(same_parts_of_second[first_head]) }}">{{ first_head }}</td>
124+
<td>{{ second_head }}</td>
125+
{% set head_percent = same_parts_of_second[first_head].pop(0).percent %}
126+
{% if head_percent > threshold %}
127+
<td style="background-color: rgb(255, 200, 200); font-weight: bold;">{{ head_percent }}</td>
128+
{% else %}
129+
<td>{{ head_percent }}</td>
130+
{% endif %}
131+
</tr>
132+
{% for same_head_info in same_parts_of_second[first_head] %}
133+
<tr class="table__row">
134+
<td>{{ same_head_info.name }}</td>
135+
{% if same_head_info.percent > threshold %}
136+
<td style="background-color: rgb(255, 200, 200); font-weight: bold;">{{ same_head_info.percent }}</td>
137+
{% else %}
138+
<td>{{ same_head_info.percent }}</td>
139+
{% endif %}
140+
</tr>
141+
{% endfor %}
138142
{% endif %}
139-
</tr>
140-
{% endfor %}
141143
{% endfor %}
142144
</table>
143145
<table align="center" style="display: inline-table;">
@@ -148,27 +150,29 @@
148150
<th>{{ _("Similarity") }}, %</th>
149151
</tr>
150152
{% for first_head in same_parts_of_first %}
151-
{% set second_head = same_parts_of_first[first_head][0].name %}
152-
<tr class="table__row">
153-
<td rowspan="{{ len(same_parts_of_first[first_head]) }}">{{ first_head }}</td>
154-
<td>{{ second_head }}</td>
155-
{% set head_percent = same_parts_of_first[first_head].pop(0).percent %}
156-
{% if head_percent > threshold %}
157-
<td style="background-color: rgb(255, 200, 200); font-weight: bold;">{{ head_percent }}</td>
158-
{% else %}
159-
<td>{{ head_percent }}</td>
160-
{% endif %}
161-
</tr>
162-
{% for same_head_info in same_parts_of_first[first_head] %}
163-
<tr class="table__row">
164-
<td>{{ same_head_info.name }}</td>
165-
{% if same_head_info.percent > threshold %}
166-
<td style="background-color: rgb(255, 200, 200); font-weight: bold;">{{ same_head_info.percent }}</td>
167-
{% else %}
168-
<td>{{ same_head_info.percent }}</td>
153+
{% if same_parts_of_first[first_head] %}
154+
{% set second_head = same_parts_of_first[first_head][0].name %}
155+
<tr class="table__row">
156+
<td rowspan="{{ len(same_parts_of_first[first_head]) }}">{{ first_head }}</td>
157+
<td>{{ second_head }}</td>
158+
{% set head_percent = same_parts_of_first[first_head].pop(0).percent %}
159+
{% if head_percent > threshold %}
160+
<td style="background-color: rgb(255, 200, 200); font-weight: bold;">{{ head_percent }}</td>
161+
{% else %}
162+
<td>{{ head_percent }}</td>
163+
{% endif %}
164+
</tr>
165+
{% for same_head_info in same_parts_of_first[first_head] %}
166+
<tr class="table__row">
167+
<td>{{ same_head_info.name }}</td>
168+
{% if same_head_info.percent > threshold %}
169+
<td style="background-color: rgb(255, 200, 200); font-weight: bold;">{{ same_head_info.percent }}</td>
170+
{% else %}
171+
<td>{{ same_head_info.percent }}</td>
172+
{% endif %}
173+
</tr>
174+
{% endfor %}
169175
{% endif %}
170-
</tr>
171-
{% endfor %}
172176
{% endfor %}
173177
</table>
174178
</div>

0 commit comments

Comments
 (0)