Code Duplication    Length = 48-49 lines in 2 locations

myems-api/excelexporters/combinedequipmentenergycategory.py 1 location

@@ 817-865 (lines=49) @@
814
                current_row_number += 2
815
816
    ####################################################################################################################
817
    if "associated_equipment" not in report.keys() or \
818
            "energy_category_names" not in report['associated_equipment'].keys() or \
819
            len(report['associated_equipment']["energy_category_names"]) == 0 \
820
            or 'associated_equipment_names_array' not in report['associated_equipment'].keys() \
821
            or report['associated_equipment']['associated_equipment_names_array'] is None \
822
            or len(report['associated_equipment']['associated_equipment_names_array']) == 0 \
823
            or len(report['associated_equipment']['associated_equipment_names_array'][0]) == 0:
824
        pass
825
    else:
826
        associated_equipment = report['associated_equipment']
827
828
        ws['B' + str(current_row_number)].font = title_font
829
        ws['B' + str(current_row_number)] = name + ' ' + _('Associated Equipment Data')
830
831
        current_row_number += 1
832
833
        ws.row_dimensions[current_row_number].height = 60
834
        ws['B' + str(current_row_number)].fill = table_fill
835
        ws['B' + str(current_row_number)].font = name_font
836
        ws['B' + str(current_row_number)].alignment = c_c_alignment
837
        ws['B' + str(current_row_number)].border = f_border
838
        ws['B' + str(current_row_number)] = _('Associated Equipment')
839
        ca_len = len(associated_equipment['energy_category_names'])
840
        for i in range(0, ca_len):
841
            row = chr(ord('C') + i)
842
            ws[row + str(current_row_number)].fill = table_fill
843
            ws[row + str(current_row_number)].font = name_font
844
            ws[row + str(current_row_number)].alignment = c_c_alignment
845
            ws[row + str(current_row_number)].border = f_border
846
            ws[row + str(current_row_number)] = \
847
                associated_equipment['energy_category_names'][i] + " (" + associated_equipment['units'][i] + ")"
848
849
        associated_equipment_len = len(associated_equipment['associated_equipment_names_array'][0])
850
        for i in range(0, associated_equipment_len):
851
            current_row_number += 1
852
            row = str(current_row_number)
853
854
            ws['B' + row].font = title_font
855
            ws['B' + row].alignment = c_c_alignment
856
            ws['B' + row] = associated_equipment['associated_equipment_names_array'][0][i]
857
            ws['B' + row].border = f_border
858
            for j in range(0, ca_len):
859
                
860
                col = chr(ord('C') + j)
861
                ws[col + row].font = title_font
862
                ws[col + row].alignment = c_c_alignment
863
                ws[col + row] = round(associated_equipment['subtotals_array'][j][i], 2) \
864
                    if associated_equipment['subtotals_array'][j][i] is not None else ''
865
                ws[col + row].border = f_border
866
    ####################################################################################################################
867
    current_sheet_parameters_row_number = table_start_draw_flag + len(reporting_period_data['names']) * 6 + 1
868
    ####################################################################################################################

myems-api/excelexporters/combinedequipmentstatistics.py 1 location

@@ 633-680 (lines=48) @@
630
                current_row_number += 2
631
632
    ####################################################################################################################
633
    if "associated_equipment" not in report.keys() or \
634
            "energy_category_names" not in report['associated_equipment'].keys() or \
635
            len(report['associated_equipment']["energy_category_names"]) == 0 \
636
            or 'associated_equipment_names_array' not in report['associated_equipment'].keys() \
637
            or report['associated_equipment']['associated_equipment_names_array'] is None \
638
            or len(report['associated_equipment']['associated_equipment_names_array']) == 0 \
639
            or len(report['associated_equipment']['associated_equipment_names_array'][0]) == 0:
640
        pass
641
    else:
642
        associated_equipment = report['associated_equipment']
643
644
        ws['B' + str(current_row_number)].font = title_font
645
        ws['B' + str(current_row_number)] = name + ' ' + _('Associated Equipment Data')
646
647
        current_row_number += 1
648
649
        ws.row_dimensions[current_row_number].height = 60
650
        ws['B' + str(current_row_number)].fill = table_fill
651
        ws['B' + str(current_row_number)].font = name_font
652
        ws['B' + str(current_row_number)].alignment = c_c_alignment
653
        ws['B' + str(current_row_number)].border = f_border
654
        ws['B' + str(current_row_number)] = _('Associated Equipment')
655
        ca_len = len(associated_equipment['energy_category_names'])
656
        for i in range(0, ca_len):
657
            row = chr(ord('C') + i)
658
            ws[row + str(current_row_number)].fill = table_fill
659
            ws[row + str(current_row_number)].font = name_font
660
            ws[row + str(current_row_number)].alignment = c_c_alignment
661
            ws[row + str(current_row_number)].border = f_border
662
            ws[row + str(current_row_number)] = \
663
                associated_equipment['energy_category_names'][i] + " (" + associated_equipment['units'][i] + ")"
664
665
        associated_equipment_len = len(associated_equipment['associated_equipment_names_array'][0])
666
        for i in range(0, associated_equipment_len):
667
            current_row_number += 1
668
            row = str(current_row_number)
669
670
            ws['B' + row].font = title_font
671
            ws['B' + row].alignment = c_c_alignment
672
            ws['B' + row] = associated_equipment['associated_equipment_names_array'][0][i]
673
            ws['B' + row].border = f_border
674
            for j in range(0, ca_len):
675
                col = chr(ord('C') + j)
676
                ws[col + row].font = title_font
677
                ws[col + row].alignment = c_c_alignment
678
                ws[col + row] = round(associated_equipment['subtotals_array'][j][i], 2) \
679
                    if associated_equipment['subtotals_array'][j][i] is not None else ''
680
                ws[col + row].border = f_border
681
    ####################################################################################################################
682
    current_sheet_parameters_row_number = table_start_draw_flag + len(reporting_period_data['names']) * 6 + 1
683
    if 'parameters' not in report.keys() or \