Code Duplication    Length = 48-49 lines in 2 locations

myems-api/excelexporters/combinedequipmentenergycategory.py 1 location

@@ 800-848 (lines=49) @@
797
                current_row_number += 2
798
799
    ####################################################################################################################
800
    if "associated_equipment" not in report.keys() or \
801
            "energy_category_names" not in report['associated_equipment'].keys() or \
802
            len(report['associated_equipment']["energy_category_names"]) == 0 \
803
            or 'associated_equipment_names_array' not in report['associated_equipment'].keys() \
804
            or report['associated_equipment']['associated_equipment_names_array'] is None \
805
            or len(report['associated_equipment']['associated_equipment_names_array']) == 0 \
806
            or len(report['associated_equipment']['associated_equipment_names_array'][0]) == 0:
807
        pass
808
    else:
809
        associated_equipment = report['associated_equipment']
810
811
        ws['B' + str(current_row_number)].font = title_font
812
        ws['B' + str(current_row_number)] = name + ' ' + _('Associated Equipment Data')
813
814
        current_row_number += 1
815
816
        ws.row_dimensions[current_row_number].height = 60
817
        ws['B' + str(current_row_number)].fill = table_fill
818
        ws['B' + str(current_row_number)].font = name_font
819
        ws['B' + str(current_row_number)].alignment = c_c_alignment
820
        ws['B' + str(current_row_number)].border = f_border
821
        ws['B' + str(current_row_number)] = _('Associated Equipment')
822
        ca_len = len(associated_equipment['energy_category_names'])
823
        for i in range(0, ca_len):
824
            row = chr(ord('C') + i)
825
            ws[row + str(current_row_number)].fill = table_fill
826
            ws[row + str(current_row_number)].font = name_font
827
            ws[row + str(current_row_number)].alignment = c_c_alignment
828
            ws[row + str(current_row_number)].border = f_border
829
            ws[row + str(current_row_number)] = \
830
                associated_equipment['energy_category_names'][i] + " (" + associated_equipment['units'][i] + ")"
831
832
        associated_equipment_len = len(associated_equipment['associated_equipment_names_array'][0])
833
        for i in range(0, associated_equipment_len):
834
            current_row_number += 1
835
            row = str(current_row_number)
836
837
            ws['B' + row].font = title_font
838
            ws['B' + row].alignment = c_c_alignment
839
            ws['B' + row] = associated_equipment['associated_equipment_names_array'][0][i]
840
            ws['B' + row].border = f_border
841
            for j in range(0, ca_len):
842
                
843
                col = chr(ord('C') + j)
844
                ws[col + row].font = title_font
845
                ws[col + row].alignment = c_c_alignment
846
                ws[col + row] = round2(associated_equipment['subtotals_array'][j][i], 2) \
847
                    if associated_equipment['subtotals_array'][j][i] is not None else ''
848
                ws[col + row].border = f_border
849
    ####################################################################################################################
850
    current_sheet_parameters_row_number = table_start_draw_flag + len(reporting_period_data['names']) * 6 + 1
851
    ####################################################################################################################

myems-api/excelexporters/combinedequipmentstatistics.py 1 location

@@ 615-662 (lines=48) @@
612
                current_row_number += 2
613
614
    ####################################################################################################################
615
    if "associated_equipment" not in report.keys() or \
616
            "energy_category_names" not in report['associated_equipment'].keys() or \
617
            len(report['associated_equipment']["energy_category_names"]) == 0 \
618
            or 'associated_equipment_names_array' not in report['associated_equipment'].keys() \
619
            or report['associated_equipment']['associated_equipment_names_array'] is None \
620
            or len(report['associated_equipment']['associated_equipment_names_array']) == 0 \
621
            or len(report['associated_equipment']['associated_equipment_names_array'][0]) == 0:
622
        pass
623
    else:
624
        associated_equipment = report['associated_equipment']
625
626
        ws['B' + str(current_row_number)].font = title_font
627
        ws['B' + str(current_row_number)] = name + ' ' + _('Associated Equipment Data')
628
629
        current_row_number += 1
630
631
        ws.row_dimensions[current_row_number].height = 60
632
        ws['B' + str(current_row_number)].fill = table_fill
633
        ws['B' + str(current_row_number)].font = name_font
634
        ws['B' + str(current_row_number)].alignment = c_c_alignment
635
        ws['B' + str(current_row_number)].border = f_border
636
        ws['B' + str(current_row_number)] = _('Associated Equipment')
637
        ca_len = len(associated_equipment['energy_category_names'])
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
                associated_equipment['energy_category_names'][i] + " (" + associated_equipment['units'][i] + ")"
646
647
        associated_equipment_len = len(associated_equipment['associated_equipment_names_array'][0])
648
        for i in range(0, associated_equipment_len):
649
            current_row_number += 1
650
            row = str(current_row_number)
651
652
            ws['B' + row].font = title_font
653
            ws['B' + row].alignment = c_c_alignment
654
            ws['B' + row] = associated_equipment['associated_equipment_names_array'][0][i]
655
            ws['B' + row].border = f_border
656
            for j in range(0, ca_len):
657
                col = chr(ord('C') + j)
658
                ws[col + row].font = title_font
659
                ws[col + row].alignment = c_c_alignment
660
                ws[col + row] = round2(associated_equipment['subtotals_array'][j][i], 2) \
661
                    if associated_equipment['subtotals_array'][j][i] is not None else ''
662
                ws[col + row].border = f_border
663
    ####################################################################################################################
664
    current_sheet_parameters_row_number = table_start_draw_flag + len(reporting_period_data['names']) * 6 + 1
665
    if 'parameters' not in report.keys() or \