Code Duplication    Length = 28-28 lines in 2 locations

myems-api/excelexporters/metercomparison.py 2 locations

@@ 193-220 (lines=28) @@
190
        ws['C8'] = round2(reporting_period_data1['total_in_category'], 2)
191
        ws['C8'].border = f_border
192
193
    if "values" not in report['reporting_period2'].keys() or len(report['reporting_period2']['values']) == 0:
194
        for i in range(11, 14 + 1):
195
            ws.row_dimensions[i].height = 0.1
196
    else:
197
        reporting_period_data2 = report['reporting_period2']
198
199
        ws.row_dimensions[12].height = 60
200
        ws['B11'].font = title_font
201
        ws['B11'].alignment = c_c_alignment
202
        ws['B11'].fill = table_fill
203
        ws['B11'].border = f_border
204
        ws['B11'] = name2
205
206
        ws['B12'].font = title_font
207
        ws['B12'].alignment = c_c_alignment
208
        ws['B12'] = _('Consumption')
209
        ws['B12'].border = f_border
210
211
        ws['C11'].fill = table_fill
212
        ws['C11'].font = name_font
213
        ws['C11'].alignment = c_c_alignment
214
        ws['C11'] = report['meter2']['energy_category_name'] + " (" + report['meter2']['unit_of_measure'] + ")"
215
        ws['C11'].border = f_border
216
217
        ws['C12'].font = name_font
218
        ws['C12'].alignment = c_c_alignment
219
        ws['C12'] = round2(reporting_period_data2['total_in_category'], 2)
220
        ws['C12'].border = f_border
221
222
    ####################################################################################################################
223
    # Second: Detailed Data
@@ 164-191 (lines=28) @@
161
    # 11: meter2 table title
162
    # 12~13: meter2 table_data
163
    ####################################################################################################################
164
    if "values" not in report['reporting_period1'].keys() or len(report['reporting_period1']['values']) == 0:
165
        for i in range(6, 9 + 1):
166
            ws.row_dimensions[i].height = 0.1
167
    else:
168
        reporting_period_data1 = report['reporting_period1']
169
170
        ws.row_dimensions[7].height = 60
171
        ws['B7'].font = title_font
172
        ws['B7'].alignment = c_c_alignment
173
        ws['B7'] = name1
174
        ws['B7'].fill = table_fill
175
        ws['B7'].border = f_border
176
177
        ws['B8'].font = title_font
178
        ws['B8'].alignment = c_c_alignment
179
        ws['B8'] = _('Consumption')
180
        ws['B8'].border = f_border
181
182
        ws['C7'].fill = table_fill
183
        ws['C7'].font = name_font
184
        ws['C7'].alignment = c_c_alignment
185
        ws['C7'] = report['meter1']['energy_category_name'] + " (" + report['meter1']['unit_of_measure'] + ")"
186
        ws['C7'].border = f_border
187
188
        ws['C8'].font = name_font
189
        ws['C8'].alignment = c_c_alignment
190
        ws['C8'] = round2(reporting_period_data1['total_in_category'], 2)
191
        ws['C8'].border = f_border
192
193
    if "values" not in report['reporting_period2'].keys() or len(report['reporting_period2']['values']) == 0:
194
        for i in range(11, 14 + 1):