def validate_samples(self):
        """Scan through the SampleData values and make sure
        that each one is correct
        """

        bsc = getToolByName(self, 'bika_setup_catalog')
        keywords = bsc.uniqueValuesFor('getKeyword')
        profiles = []
        for p in bsc(portal_type='AnalysisProfile'):
            p = p.getObject()
            profiles.append(p.Title())
            profiles.append(p.getProfileKey())

        row_nr = 0
        for gridrow in self.getSampleData():
            row_nr += 1

            # validate against sample and ar schemas
            for k, v in gridrow.items():
                if k in ['Analysis', 'Profiles']:
                    break
                if k in sample_schema:
                    try:
                        self.validate_against_schema(
                            sample_schema, row_nr, k, v)
                        continue
                    except ValueError as e:
                        self.error(e.message)
                        break
                if k in ar_schema:
                    try:
                        self.validate_against_schema(
                            ar_schema, row_nr, k, v)
                    except ValueError as e:
                        self.error(e.message)

            an_cnt = 0
            for v in gridrow['Analyses']:
                if v and v not in keywords:
                    self.error("Row %s: value is invalid (%s=%s)" %
                               ('Analysis keyword', row_nr, v))
                else:
                    an_cnt += 1
            for v in gridrow['Profiles']:
                if v and v not in profiles:
                    self.error("Row %s: value is invalid (%s=%s)" %
                               ('Profile Title', row_nr, v))
                else:
                    an_cnt += 1
            if not an_cnt:
                self.error("Row %s: No valid analyses or profiles" % row_nr)
def validate_samples ( self ) : bsc = getToolByName ( self , 'bika_setup_catalog' ) keywords = bsc . uniqueValuesFor ( 'getKeyword' ) profiles = [ ] for p in bsc ( portal_type = 'AnalysisProfile' ) : p = p . getObject ( ) profiles . append ( p . Title ( ) ) profiles . append ( p . getProfileKey ( ) ) row_nr = 0 for gridrow in self . getSampleData ( ) : row_nr += 1 for k , v in gridrow . items ( ) : if k in [ 'Analysis' , 'Profiles' ] : break if k in sample_schema : try : self . validate_against_schema ( sample_schema , row_nr , k , v ) continue except ValueError as e : self . error ( e . message ) break if k in ar_schema : try : self . validate_against_schema ( ar_schema , row_nr , k , v ) except ValueError as e : self . error ( e . message ) an_cnt = 0 for v in gridrow [ 'Analyses' ] : if v and v not in keywords : self . error ( "Row %s: value is invalid (%s=%s)" % ( 'Analysis keyword' , row_nr , v ) ) else : an_cnt += 1 for v in gridrow [ 'Profiles' ] : if v and v not in profiles : self . error ( "Row %s: value is invalid (%s=%s)" % ( 'Profile Title' , row_nr , v ) ) else : an_cnt += 1 if not an_cnt : self . error ( "Row %s: No valid analyses or profiles" % row_nr )
Scan through the SampleData values and make sure
        that each one is correct