Code Duplication    Length = 11-12 lines in 4 locations

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

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