Code Duplication    Length = 11-12 lines in 4 locations

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

@@ 951-962 (lines=12) @@
948
                    Remarks=row.get('remarks', ''),
949
                )
950
                # Attaching the Report Certificate if exists
951
                if row.get('report', None):
952
                    path = resource_filename(
953
                        self.dataset_project,
954
                        "setupdata/%s/%s" % (self.dataset_name,
955
                                             row['report'])
956
                    )
957
                    try:
958
                        file_data = read_file(path)
959
                        obj.setDocument(file_data)
960
                    except Exception as msg:
961
                        file_data = None
962
                        logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
963
964
                # Getting lab contacts
965
                bsc = getToolByName(self.context, SETUP_CATALOG)
@@ 819-830 (lines=12) @@
816
                obj.setMethod(method)
817
818
            # Attaching the instrument's photo
819
            if row.get('Photo', None):
820
                path = resource_filename(
821
                    self.dataset_project,
822
                    "setupdata/%s/%s" % (self.dataset_name,
823
                                         row['Photo'])
824
                )
825
                try:
826
                    file_data = read_file(path)
827
                    obj.setPhoto(file_data)
828
                except Exception as msg:
829
                    file_data = None
830
                    logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
831
832
            # Attaching the Installation Certificate if exists
833
            if row.get('InstalationCertificate', None):
@@ 833-843 (lines=11) @@
830
                    logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
831
832
            # Attaching the Installation Certificate if exists
833
            if row.get('InstalationCertificate', None):
834
                path = resource_filename(
835
                    self.dataset_project,
836
                    "setupdata/%s/%s" % (self.dataset_name,
837
                                         row['InstalationCertificate'])
838
                )
839
                try:
840
                    file_data = read_file(path)
841
                    obj.setInstallationCertificate(file_data)
842
                except Exception as msg:
843
                    logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
844
845
            # Attaching the Instrument's manual if exists
846
            if row.get('UserManualFile', None):
@@ 1315-1325 (lines=11) @@
1312
                    if methods.getObject().get('MethodID', '') != '' and methods.getObject.get('MethodID', '') == obj['MethodID']:
1313
                        obj.edit(MethodID='')
1314
1315
                if row['MethodDocument']:
1316
                    path = resource_filename(
1317
                        self.dataset_project,
1318
                        "setupdata/%s/%s" % (self.dataset_name,
1319
                                             row['MethodDocument'])
1320
                    )
1321
                    try:
1322
                        file_data = read_file(path)
1323
                        obj.setMethodDocument(file_data)
1324
                    except Exception as msg:
1325
                        logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
1326
1327
                obj.unmarkCreationFlag()
1328
                renameAfterCreation(obj)