Code Duplication    Length = 50-50 lines in 3 locations

myems-api/excelexporters/combinedequipmentsaving.py 1 location

@@ 739-788 (lines=50) @@
736
                current_row_number += 2
737
738
    ####################################################################################################################
739
    if "associated_equipment" not in report.keys() or \
740
            "energy_category_names" not in report['associated_equipment'].keys() or \
741
            len(report['associated_equipment']["energy_category_names"]) == 0 \
742
            or 'associated_equipment_names_array' not in report['associated_equipment'].keys() \
743
            or report['associated_equipment']['associated_equipment_names_array'] is None \
744
            or len(report['associated_equipment']['associated_equipment_names_array']) == 0 \
745
            or len(report['associated_equipment']['associated_equipment_names_array'][0]) == 0:
746
        pass
747
    else:
748
        associated_equipment = report['associated_equipment']
749
750
        ws['B' + str(current_row_number)].font = title_font
751
        ws['B' + str(current_row_number)] = name + ' ' + _('Associated Equipment Data')
752
753
        current_row_number += 1
754
755
        ws.row_dimensions[current_row_number].height = 60
756
        ws['B' + str(current_row_number)].fill = table_fill
757
        ws['B' + str(current_row_number)].font = name_font
758
        ws['B' + str(current_row_number)].alignment = c_c_alignment
759
        ws['B' + str(current_row_number)].border = f_border
760
        ws['B' + str(current_row_number)] = _('Associated Equipment')
761
        ca_len = len(associated_equipment['energy_category_names'])
762
763
        for i in range(0, ca_len):
764
            row = chr(ord('C') + i)
765
            ws[row + str(current_row_number)].fill = table_fill
766
            ws[row + str(current_row_number)].font = name_font
767
            ws[row + str(current_row_number)].alignment = c_c_alignment
768
            ws[row + str(current_row_number)].border = f_border
769
            ws[row + str(current_row_number)] = \
770
                associated_equipment['energy_category_names'][i] + " (" + associated_equipment['units'][i] + ")"
771
772
        associated_equipment_len = len(associated_equipment['associated_equipment_names_array'][0])
773
774
        for i in range(0, associated_equipment_len):
775
            current_row_number += 1
776
            row = str(current_row_number)
777
778
            ws['B' + row].font = title_font
779
            ws['B' + row].alignment = c_c_alignment
780
            ws['B' + row] = associated_equipment['associated_equipment_names_array'][0][i]
781
            ws['B' + row].border = f_border
782
783
            for j in range(0, ca_len):
784
                col = chr(ord('C') + j)
785
                ws[col + row].font = title_font
786
                ws[col + row].alignment = c_c_alignment
787
                ws[col + row] = round(associated_equipment['subtotals_saving_array'][j][i], 2)
788
                ws[col + row].border = f_border
789
790
    ####################################################################################################################
791
    current_sheet_parameters_row_number = table_start_draw_flag + len(reporting_period_data['names']) * 6 + 1

myems-api/excelexporters/combinedequipmentenergyitem.py 1 location

@@ 614-663 (lines=50) @@
611
                ws.add_chart(line, chart_cell)
612
613
    ####################################################################################################################
614
    if "associated_equipment" not in report.keys() or \
615
            "energy_item_names" not in report['associated_equipment'].keys() or \
616
            len(report['associated_equipment']["energy_item_names"]) == 0 \
617
            or 'associated_equipment_names_array' not in report['associated_equipment'].keys() \
618
            or report['associated_equipment']['associated_equipment_names_array'] is None \
619
            or len(report['associated_equipment']['associated_equipment_names_array']) == 0 \
620
            or len(report['associated_equipment']['associated_equipment_names_array'][0]) == 0:
621
        pass
622
    else:
623
        associated_equipment = report['associated_equipment']
624
625
        ws['B' + str(current_row_number)].font = title_font
626
        ws['B' + str(current_row_number)] = name + ' ' + _('Associated Equipment Data')
627
628
        current_row_number += 1
629
630
        ws.row_dimensions[current_row_number].height = 60
631
        ws['B' + str(current_row_number)].fill = table_fill
632
        ws['B' + str(current_row_number)].font = name_font
633
        ws['B' + str(current_row_number)].alignment = c_c_alignment
634
        ws['B' + str(current_row_number)].border = f_border
635
        ws['B' + str(current_row_number)] = _('Associated Equipment')
636
        ca_len = len(associated_equipment['energy_item_names'])
637
638
        for i in range(0, ca_len):
639
            row = chr(ord('C') + i)
640
            ws[row + str(current_row_number)].fill = table_fill
641
            ws[row + str(current_row_number)].font = name_font
642
            ws[row + str(current_row_number)].alignment = c_c_alignment
643
            ws[row + str(current_row_number)].border = f_border
644
            ws[row + str(current_row_number)] = \
645
                reporting_period_data['names'][i] + " (" + reporting_period_data['units'][i] + ")"
646
647
        associated_equipment_len = len(associated_equipment['associated_equipment_names_array'][0])
648
649
        for i in range(0, associated_equipment_len):
650
            current_row_number += 1
651
            row = str(current_row_number)
652
653
            ws['B' + row].font = title_font
654
            ws['B' + row].alignment = c_c_alignment
655
            ws['B' + row] = associated_equipment['associated_equipment_names_array'][0][i]
656
            ws['B' + row].border = f_border
657
658
            for j in range(0, ca_len):
659
                col = chr(ord('C') + j)
660
                ws[col + row].font = title_font
661
                ws[col + row].alignment = c_c_alignment
662
                ws[col + row] = round(associated_equipment['subtotals_array'][j][i], 2)
663
                ws[col + row].border = f_border
664
    ####################################################################################################################
665
    current_sheet_parameters_row_number = chart_start_row_number + 1
666
    has_parameters_names_and_timestamps_and_values_data = True

myems-api/excelexporters/combinedequipmentoutput.py 1 location

@@ 557-606 (lines=50) @@
554
                current_row_number += 2
555
556
    ####################################################################################################################
557
    if "associated_equipment" not in report.keys() or \
558
            "energy_category_names" not in report['associated_equipment'].keys() or \
559
            len(report['associated_equipment']["energy_category_names"]) == 0 \
560
            or 'associated_equipment_names_array' not in report['associated_equipment'].keys() \
561
            or report['associated_equipment']['associated_equipment_names_array'] is None \
562
            or len(report['associated_equipment']['associated_equipment_names_array']) == 0 \
563
            or len(report['associated_equipment']['associated_equipment_names_array'][0]) == 0:
564
        pass
565
    else:
566
        associated_equipment = report['associated_equipment']
567
568
        ws['B' + str(current_row_number)].font = title_font
569
        ws['B' + str(current_row_number)] = name + ' ' + _('Associated Equipment Data')
570
571
        current_row_number += 1
572
573
        ws.row_dimensions[current_row_number].height = 60
574
        ws['B' + str(current_row_number)].fill = table_fill
575
        ws['B' + str(current_row_number)].font = name_font
576
        ws['B' + str(current_row_number)].alignment = c_c_alignment
577
        ws['B' + str(current_row_number)].border = f_border
578
        ws['B' + str(current_row_number)] = _('Associated Equipment')
579
        ca_len = len(associated_equipment['energy_category_names'])
580
581
        for i in range(0, ca_len):
582
            row = chr(ord('C') + i)
583
            ws[row + str(current_row_number)].fill = table_fill
584
            ws[row + str(current_row_number)].font = name_font
585
            ws[row + str(current_row_number)].alignment = c_c_alignment
586
            ws[row + str(current_row_number)].border = f_border
587
            ws[row + str(current_row_number)] = \
588
                associated_equipment['energy_category_names'][i] + " (" + associated_equipment['units'][i] + ")"
589
590
        associated_equipment_len = len(associated_equipment['associated_equipment_names_array'][0])
591
592
        for i in range(0, associated_equipment_len):
593
            current_row_number += 1
594
            row = str(current_row_number)
595
596
            ws['B' + row].font = title_font
597
            ws['B' + row].alignment = c_c_alignment
598
            ws['B' + row] = associated_equipment['associated_equipment_names_array'][0][i]
599
            ws['B' + row].border = f_border
600
601
            for j in range(0, ca_len):
602
                col = chr(ord('C') + j)
603
                ws[col + row].font = title_font
604
                ws[col + row].alignment = c_c_alignment
605
                ws[col + row] = round(associated_equipment['subtotals_array'][j][i], 2)
606
                ws[col + row].border = f_border
607
    ####################################################################################################################
608
    current_sheet_parameters_row_number = table_start_draw_flag + len(reporting_period_data['names']) * 6 + 1
609
    if 'parameters' not in report.keys() or \