Code Duplication    Length = 11-12 lines in 4 locations

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

@@ 936-947 (lines=12) @@
933
                    Remarks=row.get('remarks', ''),
934
                )
935
                # Attaching the Report Certificate if exists
936
                if row.get('report', None):
937
                    path = resource_filename(
938
                        self.dataset_project,
939
                        "setupdata/%s/%s" % (self.dataset_name,
940
                                             row['report'])
941
                    )
942
                    try:
943
                        file_data = read_file(path)
944
                        obj.setDocument(file_data)
945
                    except Exception as msg:
946
                        file_data = None
947
                        logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
948
949
                # Getting lab contacts
950
                bsc = getToolByName(self.context, 'bika_setup_catalog')
@@ 804-815 (lines=12) @@
801
                obj.setMethod(method)
802
803
            # Attaching the instrument's photo
804
            if row.get('Photo', None):
805
                path = resource_filename(
806
                    self.dataset_project,
807
                    "setupdata/%s/%s" % (self.dataset_name,
808
                                         row['Photo'])
809
                )
810
                try:
811
                    file_data = read_file(path)
812
                    obj.setPhoto(file_data)
813
                except Exception as msg:
814
                    file_data = None
815
                    logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
816
817
            # Attaching the Installation Certificate if exists
818
            if row.get('InstalationCertificate', None):
@@ 1314-1324 (lines=11) @@
1311
                    if methods.getObject().get('MethodID', '') != '' and methods.getObject.get('MethodID', '') == obj['MethodID']:
1312
                        obj.edit(MethodID='')
1313
1314
                if row['MethodDocument']:
1315
                    path = resource_filename(
1316
                        self.dataset_project,
1317
                        "setupdata/%s/%s" % (self.dataset_name,
1318
                                             row['MethodDocument'])
1319
                    )
1320
                    try:
1321
                        file_data = read_file(path)
1322
                        obj.setMethodDocument(file_data)
1323
                    except Exception as msg:
1324
                        logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
1325
1326
                obj.unmarkCreationFlag()
1327
                renameAfterCreation(obj)
@@ 818-828 (lines=11) @@
815
                    logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
816
817
            # Attaching the Installation Certificate if exists
818
            if row.get('InstalationCertificate', None):
819
                path = resource_filename(
820
                    self.dataset_project,
821
                    "setupdata/%s/%s" % (self.dataset_name,
822
                                         row['InstalationCertificate'])
823
                )
824
                try:
825
                    file_data = read_file(path)
826
                    obj.setInstallationCertificate(file_data)
827
                except Exception as msg:
828
                    logger.warning(msg[0] + " Error on sheet: " + self.sheetname)
829
830
            # Attaching the Instrument's manual if exists
831
            if row.get('UserManualFile', None):