Code Duplication    Length = 11-12 lines in 4 locations

bika/lims/exportimport/setupdata/__init__.py 4 locations

@@ 949-960 (lines=12) @@
946
                    Remarks=row.get('remarks', ''),
947
                )
948
                # Attaching the Report Certificate if exists
949
                if row.get('report', None):
950
                    path = resource_filename(
951
                        self.dataset_project,
952
                        "setupdata/%s/%s" % (self.dataset_name,
953
                                             row['report'])
954
                    )
955
                    try:
956
                        file_data = read_file(path)
957
                        obj.setDocument(file_data)
958
                    except Exception as msg:
959
                        file_data = None
960
                        logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
961
962
                # Getting lab contacts
963
                bsc = getToolByName(self.context, 'bika_setup_catalog')
@@ 817-828 (lines=12) @@
814
                obj.setMethod(method)
815
816
            # Attaching the instrument's photo
817
            if row.get('Photo', None):
818
                path = resource_filename(
819
                    self.dataset_project,
820
                    "setupdata/%s/%s" % (self.dataset_name,
821
                                         row['Photo'])
822
                )
823
                try:
824
                    file_data = read_file(path)
825
                    obj.setPhoto(file_data)
826
                except Exception as msg:
827
                    file_data = None
828
                    logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
829
830
            # Attaching the Installation Certificate if exists
831
            if row.get('InstalationCertificate', None):
@@ 1327-1337 (lines=11) @@
1324
                    if methods.getObject().get('MethodID', '') != '' and methods.getObject.get('MethodID', '') == obj['MethodID']:
1325
                        obj.edit(MethodID='')
1326
1327
                if row['MethodDocument']:
1328
                    path = resource_filename(
1329
                        self.dataset_project,
1330
                        "setupdata/%s/%s" % (self.dataset_name,
1331
                                             row['MethodDocument'])
1332
                    )
1333
                    try:
1334
                        file_data = read_file(path)
1335
                        obj.setMethodDocument(file_data)
1336
                    except Exception as msg:
1337
                        logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
1338
1339
                obj.unmarkCreationFlag()
1340
                renameAfterCreation(obj)
@@ 831-841 (lines=11) @@
828
                    logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
829
830
            # Attaching the Installation Certificate if exists
831
            if row.get('InstalationCertificate', None):
832
                path = resource_filename(
833
                    self.dataset_project,
834
                    "setupdata/%s/%s" % (self.dataset_name,
835
                                         row['InstalationCertificate'])
836
                )
837
                try:
838
                    file_data = read_file(path)
839
                    obj.setInstallationCertificate(file_data)
840
                except Exception as msg:
841
                    logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
842
843
            # Attaching the Instrument's manual if exists
844
            if row.get('UserManualFile', None):