def _check_triple(self, triple):
        """compare triple to ontology, return error or None"""
        subj, pred, obj = triple

        if self._should_ignore_predicate(pred):
            log.info("Ignoring triple with predicate '{}'"
                     .format(self._field_name_from_uri(pred)))
            return

        classes = []
        log.warning("Possible member %s found" % pred)

        pred = self._expand_qname(pred)

        if self._namespace_from_uri(pred) not in self.allowed_namespaces:
            log.info("Member %s does not use an allowed namespace", pred)
            return

        instanceof = self._is_instance((subj, pred, obj))
        if type(instanceof) == rt.URIRef:
            instanceof = self._expand_qname(instanceof)

        if hasattr(self.schema_def, "attributes_by_class") and \
           not self.schema_def.attributes_by_class:
            log.info("Parsed ontology not found. Parsing...")
            self.schema_def.parse_ontology()

        class_invalid = self._validate_class(instanceof)
        if class_invalid:
            log.warning("Invalid class %s" % instanceof)
            return class_invalid
        # TODO - the above sometimes fails when a single object has more than
        # one rdfa type (eg <span property="schema:creator rnews:creator"
        # typeof="schema:Person rnews:Person">
        # Graph chooses the type in an arbitrary order, so it's unreliable
        # eg: http://semanticweb.com/the-impact-of-rdfa_b35003

        classes = self._superclasses_for_subject(self.graph, instanceof)
        classes.append(instanceof)

        member_invalid = self._validate_member(pred, classes, instanceof)
        if member_invalid:
            log.warning("Invalid member of class")
            return member_invalid

        dupe_invalid = self._validate_duplication((subj, pred), instanceof)
        if dupe_invalid:
            log.warning("Duplication found")
            return dupe_invalid

        # collect a list of checked attributes
        self.checked_attributes.append((subj, pred))
        log.warning("successfully validated triple, no errors")
        return
def _check_triple ( self , triple ) : subj , pred , obj = triple if self . _should_ignore_predicate ( pred ) : log . info ( "Ignoring triple with predicate '{}'" . format ( self . _field_name_from_uri ( pred ) ) ) return classes = [ ] log . warning ( "Possible member %s found" % pred ) pred = self . _expand_qname ( pred ) if self . _namespace_from_uri ( pred ) not in self . allowed_namespaces : log . info ( "Member %s does not use an allowed namespace" , pred ) return instanceof = self . _is_instance ( ( subj , pred , obj ) ) if type ( instanceof ) == rt . URIRef : instanceof = self . _expand_qname ( instanceof ) if hasattr ( self . schema_def , "attributes_by_class" ) and not self . schema_def . attributes_by_class : log . info ( "Parsed ontology not found. Parsing..." ) self . schema_def . parse_ontology ( ) class_invalid = self . _validate_class ( instanceof ) if class_invalid : log . warning ( "Invalid class %s" % instanceof ) return class_invalid classes = self . _superclasses_for_subject ( self . graph , instanceof ) classes . append ( instanceof ) member_invalid = self . _validate_member ( pred , classes , instanceof ) if member_invalid : log . warning ( "Invalid member of class" ) return member_invalid dupe_invalid = self . _validate_duplication ( ( subj , pred ) , instanceof ) if dupe_invalid : log . warning ( "Duplication found" ) return dupe_invalid self . checked_attributes . append ( ( subj , pred ) ) log . warning ( "successfully validated triple, no errors" ) return
compare triple to ontology, return error or None