Code Duplication    Length = 31-31 lines in 2 locations

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

@@ 890-920 (lines=31) @@
887
                notify(ObjectInitializedEvent(obj))
888
889
890
class Instrument_Calibrations(WorksheetImporter):
891
892
    def Import(self):
893
        bsc = getToolByName(self.context, 'bika_setup_catalog')
894
        for row in self.get_rows(3):
895
            if not row.get('instrument', None) or not row.get('title', None):
896
                continue
897
898
            folder = self.get_object(bsc, 'Instrument', row.get('instrument'))
899
            if folder:
900
                obj = _createObjectByType("InstrumentCalibration", folder, tmpID())
901
                obj.edit(
902
                    title=row['title'],
903
                    DownFrom=row.get('downfrom', ''),
904
                    DownTo=row.get('downto', ''),
905
                    Calibrator=row.get('calibrator', ''),
906
                    Considerations=row.get('considerations', ''),
907
                    WorkPerformed=row.get('workperformed', ''),
908
                    Remarks=row.get('remarks', ''),
909
                    DateIssued=row.get('DateIssued', ''),
910
                    ReportID=row.get('ReportID', '')
911
                )
912
                # Gettinginstrument lab contacts
913
                bsc = getToolByName(self.context, 'bika_setup_catalog')
914
                lab_contacts = [o.getObject() for o in bsc(portal_type="LabContact", nactive_state='active')]
915
                for contact in lab_contacts:
916
                    if contact.getFullname() == row.get('Worker', ''):
917
                        obj.setWorker(contact.UID())
918
                obj.unmarkCreationFlag()
919
                renameAfterCreation(obj)
920
                notify(ObjectInitializedEvent(obj))
921
922
923
class Instrument_Certifications(WorksheetImporter):
@@ 857-887 (lines=31) @@
854
            notify(ObjectInitializedEvent(obj))
855
856
857
class Instrument_Validations(WorksheetImporter):
858
859
    def Import(self):
860
        bsc = getToolByName(self.context, 'bika_setup_catalog')
861
        for row in self.get_rows(3):
862
            if not row.get('instrument', None) or not row.get('title', None):
863
                continue
864
865
            folder = self.get_object(bsc, 'Instrument', row.get('instrument'))
866
            if folder:
867
                obj = _createObjectByType("InstrumentValidation", folder, tmpID())
868
                obj.edit(
869
                    title=row['title'],
870
                    DownFrom=row.get('downfrom', ''),
871
                    DownTo=row.get('downto', ''),
872
                    Validator=row.get('validator', ''),
873
                    Considerations=row.get('considerations', ''),
874
                    WorkPerformed=row.get('workperformed', ''),
875
                    Remarks=row.get('remarks', ''),
876
                    DateIssued=row.get('DateIssued', ''),
877
                    ReportID=row.get('ReportID', '')
878
                )
879
                # Getting lab contacts
880
                bsc = getToolByName(self.context, 'bika_setup_catalog')
881
                lab_contacts = [o.getObject() for o in bsc(portal_type="LabContact", is_active=True)]
882
                for contact in lab_contacts:
883
                    if contact.getFullname() == row.get('Worker', ''):
884
                        obj.setWorker(contact.UID())
885
                obj.unmarkCreationFlag()
886
                renameAfterCreation(obj)
887
                notify(ObjectInitializedEvent(obj))
888
889
890
class Instrument_Calibrations(WorksheetImporter):