Code Duplication    Length = 11-12 lines in 4 locations

src/senaite/core/exportimport/setupdata/__init__.py 4 locations

@@ 989-1000 (lines=12) @@
986
                    Remarks=row.get('remarks', ''),
987
                )
988
                # Attaching the Report Certificate if exists
989
                if row.get('report', None):
990
                    path = resource_filename(
991
                        self.dataset_project,
992
                        "setupdata/%s/%s" % (self.dataset_name,
993
                                             row['report'])
994
                    )
995
                    try:
996
                        file_data = read_file(path)
997
                        obj.setDocument(file_data)
998
                    except Exception as msg:
999
                        file_data = None
1000
                        logger.warning(
1001
                            msg[0] + " Error on sheet: " + self.sheetname)
1002
1003
                # Getting lab contacts
@@ 847-858 (lines=12) @@
844
                obj.setMethod(method)
845
846
            # Attaching the instrument's photo
847
            if row.get('Photo', None):
848
                path = resource_filename(
849
                    self.dataset_project,
850
                    "setupdata/%s/%s" % (self.dataset_name,
851
                                         row['Photo'])
852
                )
853
                try:
854
                    file_data = read_file(path)
855
                    obj.setPhoto(file_data)
856
                except Exception as msg:
857
                    file_data = None
858
                    logger.warning(
859
                        msg[0] + " Error on sheet: " + self.sheetname)
860
861
            # Attaching the Installation Certificate if exists
@@ 1360-1370 (lines=11) @@
1357
                    if methods.getObject().get('MethodID', '') != '' and methods.getObject.get('MethodID', '') == obj['MethodID']:
1358
                        obj.edit(MethodID='')
1359
1360
                if row['MethodDocument']:
1361
                    path = resource_filename(
1362
                        self.dataset_project,
1363
                        "setupdata/%s/%s" % (self.dataset_name,
1364
                                             row['MethodDocument'])
1365
                    )
1366
                    try:
1367
                        file_data = read_file(path)
1368
                        obj.setMethodDocument(file_data)
1369
                    except Exception as msg:
1370
                        logger.warning(
1371
                            msg[0] + " Error on sheet: " + self.sheetname)
1372
1373
                obj.unmarkCreationFlag()
@@ 862-872 (lines=11) @@
859
                        msg[0] + " Error on sheet: " + self.sheetname)
860
861
            # Attaching the Installation Certificate if exists
862
            if row.get('InstalationCertificate', None):
863
                path = resource_filename(
864
                    self.dataset_project,
865
                    "setupdata/%s/%s" % (self.dataset_name,
866
                                         row['InstalationCertificate'])
867
                )
868
                try:
869
                    file_data = read_file(path)
870
                    obj.setInstallationCertificate(file_data)
871
                except Exception as msg:
872
                    logger.warning(
873
                        msg[0] + " Error on sheet: " + self.sheetname)
874
875
            # Attaching the Instrument's manual if exists