コード例 #1
0
    def convType(self, t, F, K=None):
        #        print "type:",t, type(t)
        """print "t:", t
        print type(t)
        print "f unis:", F.universals()
        if (K): print "k exis:", K.existentials()"""

        if isinstance(t, term.NonEmptyList):
            #convert the name of the list to an exivar and return it
            #self.convertListToRDF(t, listId, self.extra)
            #return terms.Exivar('_:' + str(t))
            return '_:' + str(t)
            #raise RuntimeError
        if t in F.universals():
            return terms.Variable(t)
        if K is not None and t in K.existentials():
            #            print "returning existential:", t
            return terms.Exivar(t)
        if isinstance(t, term.Symbol):
            return terms.URIRef(t.uri)
        if isinstance(t, term.BuiltIn):
            return t.uriref()
        if isinstance(t, term.Fragment):
            #                print "uriref:",terms.URIRef(t.uriref())
            #                print type(t.uriref())
            return terms.URIRef(t.uriref())
#        print type(t)
#        print "returning URI",t
        return str(t)
コード例 #2
0
ファイル: test_rules.py プロジェクト: mobilemadman2/rdflib-1
 def _convert(node):
     if isinstance(node, Variable):
         return terms.Variable(node)
         # return node
     elif isinstance(node, BNode):
         return terms.Exivar(node)
     elif isinstance(node, URIRef):
         # return terms.URI(node)
         return node
     elif isinstance(node, Literal):
         return node
     else:
         raise Exception("Unexpected Type: %s" % type(node))