Code Duplication    Length = 60-61 lines in 3 locations

excelexporters/tenantenergycategory.py 2 locations

@@ 379-439 (lines=61) @@
376
            len(reporting_period_data['subtotals_in_kgce']) == 0:
377
        has_kgce_data_flag = False
378
379
    if has_kgce_data_flag:
380
        ws['B' + str(current_row_number)].font = title_font
381
        ws['B' + str(current_row_number)] = name + ' 吨标准煤 (TCE) 占比'
382
383
        current_row_number += 1
384
        table_start_row_number = current_row_number
385
386
        ws.row_dimensions[current_row_number].height = 60
387
        ws['B' + str(current_row_number)].fill = table_fill
388
        ws['B' + str(current_row_number)].font = name_font
389
        ws['B' + str(current_row_number)].alignment = c_c_alignment
390
        ws['B' + str(current_row_number)].border = f_border
391
392
        ws['C' + str(current_row_number)].fill = table_fill
393
        ws['C' + str(current_row_number)].font = name_font
394
        ws['C' + str(current_row_number)].alignment = c_c_alignment
395
        ws['C' + str(current_row_number)].border = f_border
396
        ws['C' + str(current_row_number)] = '吨标准煤 (TCE) 占比'
397
398
        current_row_number += 1
399
400
        ca_len = len(reporting_period_data['names'])
401
402
        for i in range(0, ca_len):
403
            ws['B' + str(current_row_number)].font = title_font
404
            ws['B' + str(current_row_number)].alignment = c_c_alignment
405
            ws['B' + str(current_row_number)] = reporting_period_data['names'][i]
406
            ws['B' + str(current_row_number)].border = f_border
407
408
            ws['C' + str(current_row_number)].font = title_font
409
            ws['C' + str(current_row_number)].alignment = c_c_alignment
410
            ws['C' + str(current_row_number)].border = f_border
411
            ws['C' + str(current_row_number)] = round(reporting_period_data['subtotals_in_kgce'][i] / 1000, 3)
412
413
            current_row_number += 1
414
415
        table_end_row_number = current_row_number - 1
416
417
        pie = PieChart()
418
        pie.title = name + ' ' + ws.cell(column=3, row=table_start_row_number).value
419
        labels = Reference(ws, min_col=2, min_row=table_start_row_number+1, max_row=table_end_row_number)
420
        pie_data = Reference(ws, min_col=3, min_row=table_start_row_number, max_row=table_end_row_number)
421
        pie.add_data(pie_data, titles_from_data=True)
422
        pie.set_categories(labels)
423
        pie.height = 7.25
424
        pie.width = 9
425
        s1 = pie.series[0]
426
        s1.dLbls = DataLabelList()
427
        s1.dLbls.showCatName = False
428
        s1.dLbls.showVal = True
429
        s1.dLbls.showPercent = True
430
        table_cell = 'D' + str(table_start_row_number)
431
        ws.add_chart(pie, table_cell)
432
433
        if ca_len < 4:
434
            current_row_number = current_row_number - ca_len + 4
435
436
    else:
437
        for i in range(21, 29 + 1):
438
            current_row_number = 30
439
            ws.row_dimensions[i].height = 0.1
440
441
    #####################################################
442
@@ 451-510 (lines=60) @@
448
            len(reporting_period_data['subtotals_in_kgco2e']) == 0:
449
        has_kgco2e_data_flag = False
450
451
    if has_kgco2e_data_flag:
452
        ws['B' + str(current_row_number)].font = title_font
453
        ws['B' + str(current_row_number)] = name + ' 吨二氧化碳排放 (TCO2E) 占比'
454
455
        current_row_number += 1
456
        table_start_row_number = current_row_number
457
458
        ws.row_dimensions[current_row_number].height = 75
459
        ws['B' + str(current_row_number)].fill = table_fill
460
        ws['B' + str(current_row_number)].font = name_font
461
        ws['B' + str(current_row_number)].alignment = c_c_alignment
462
        ws['B' + str(current_row_number)].border = f_border
463
464
        ws['C' + str(current_row_number)].fill = table_fill
465
        ws['C' + str(current_row_number)].font = name_font
466
        ws['C' + str(current_row_number)].alignment = c_c_alignment
467
        ws['C' + str(current_row_number)].border = f_border
468
        ws['C' + str(current_row_number)] = '吨二氧化碳排放 (TCO2E) 占比'
469
470
        current_row_number += 1
471
472
        ca_len = len(reporting_period_data['names'])
473
474
        for i in range(0, ca_len):
475
            ws['B' + str(current_row_number)].font = title_font
476
            ws['B' + str(current_row_number)].alignment = c_c_alignment
477
            ws['B' + str(current_row_number)] = reporting_period_data['names'][i]
478
            ws['B' + str(current_row_number)].border = f_border
479
480
            ws['C' + str(current_row_number)].font = title_font
481
            ws['C' + str(current_row_number)].alignment = c_c_alignment
482
            ws['C' + str(current_row_number)].border = f_border
483
            ws['C' + str(current_row_number)] = round(reporting_period_data['subtotals_in_kgco2e'][i] / 1000, 3)
484
            current_row_number += 1
485
486
        table_end_row_number = current_row_number - 1
487
488
        pie = PieChart()
489
        pie.title = name + ' ' + ws.cell(column=3, row=table_start_row_number).value
490
        labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number)
491
        pie_data = Reference(ws, min_col=3, min_row=table_start_row_number, max_row=table_end_row_number)
492
        pie.add_data(pie_data, titles_from_data=True)
493
        pie.set_categories(labels)
494
        pie.height = 7.75
495
        pie.width = 9
496
        s1 = pie.series[0]
497
        s1.dLbls = DataLabelList()
498
        s1.dLbls.showCatName = False
499
        s1.dLbls.showVal = True
500
        s1.dLbls.showPercent = True
501
        table_cell = 'D' + str(table_start_row_number)
502
        ws.add_chart(pie, table_cell)
503
504
        if ca_len < 4:
505
            current_row_number = current_row_number - ca_len + 4
506
507
    else:
508
        for i in range(30, 39 + 1):
509
            current_row_number = 40
510
            ws.row_dimensions[i].height = 0.1
511
512
    ###############################################
513
    current_row_number += 1

excelexporters/tenantcost.py 1 location

@@ 354-414 (lines=61) @@
351
            len(reporting_period_data['subtotals']) == 0:
352
        has_subtotals_data_flag = False
353
354
    if has_subtotals_data_flag:
355
        ws['B' + str(current_row_number)].font = title_font
356
        ws['B' + str(current_row_number)] = name + ' 成本占比'
357
358
        current_row_number += 1
359
360
        table_start_row_number = current_row_number
361
362
        ws['B' + str(current_row_number)].fill = table_fill
363
        ws['B' + str(current_row_number)].font = name_font
364
        ws['B' + str(current_row_number)].alignment = c_c_alignment
365
        ws['B' + str(current_row_number)].border = f_border
366
367
        ws['C' + str(current_row_number)].fill = table_fill
368
        ws['C' + str(current_row_number)].font = name_font
369
        ws['C' + str(current_row_number)].alignment = c_c_alignment
370
        ws['C' + str(current_row_number)].border = f_border
371
        ws['C' + str(current_row_number)] = '成本占比'
372
373
        current_row_number += 1
374
375
        ca_len = len(reporting_period_data['names'])
376
377
        for i in range(0, ca_len):
378
            ws['B' + str(current_row_number)].font = title_font
379
            ws['B' + str(current_row_number)].alignment = c_c_alignment
380
            ws['B' + str(current_row_number)] = reporting_period_data['names'][i]
381
            ws['B' + str(current_row_number)].border = f_border
382
383
            ws['C' + str(current_row_number)].font = title_font
384
            ws['C' + str(current_row_number)].alignment = c_c_alignment
385
            ws['C' + str(current_row_number)].border = f_border
386
            ws['C' + str(current_row_number)] = round(reporting_period_data['subtotals'][i], 2)
387
388
            current_row_number += 1
389
390
        table_end_row_number = current_row_number - 1
391
392
        pie = PieChart()
393
        pie.title = name + ' 成本占比'
394
        labels = Reference(ws, min_col=2, min_row=table_start_row_number + 1, max_row=table_end_row_number)
395
        pie_data = Reference(ws, min_col=3, min_row=table_start_row_number, max_row=table_end_row_number)
396
        pie.add_data(pie_data, titles_from_data=True)
397
        pie.set_categories(labels)
398
        pie.height = 6.6
399
        pie.width = 9
400
        s1 = pie.series[0]
401
        s1.dLbls = DataLabelList()
402
        s1.dLbls.showCatName = False
403
        s1.dLbls.showVal = True
404
        s1.dLbls.showPercent = True
405
        table_cell = 'D' + str(table_start_row_number)
406
        ws.add_chart(pie, table_cell)
407
408
        if ca_len < 4:
409
            current_row_number = current_row_number - ca_len + 4
410
411
    else:
412
        for i in range(21, 29 + 1):
413
            current_row_number = 30
414
            ws.row_dimensions[i].height = 0.1
415
416
    ###############################################
417