Пример #1
0
 def iri(self, text):
     try:
         (long, local) = qname.uri_split(text)
     except qname.Unsplitable:
         long = ""
         local = text
     short = self.nsmap.getShort(long)
     if short != "rif":
         short = self.atom_prefix+short
     #self.outk(short+":"+atom_quote(local))
     self.outk(atom_quote(short+"_"+local))
Пример #2
0
 def builtin_calc(self, var, expr):
     # not currently used...
     func = expr.op.the.value.the
     if func.datatype == rifns+"iri":
         (ns, local) = qname.uri_split(func.lexrep)
         if ns == rif_bif:
             arg = expr.args.the.items
             method_name = "builtin_"+local.replace("-","_")
             debug('prolog-bi', 'looking for func ', method_name)
             attr = getattr(self, method_name, None)
             if attr:
                 attr(var, *arg)
                 return
     raise MissingBuiltin  # it's not builtin...
Пример #3
0
    def do_Expr(self, obj):
        op = obj.op.the.value.the
        if op.datatype == rifns+"iri":
            (ns, local) = qname.uri_split(op.lexrep)
            if ns == rif_bif:
                name = "builtin_"+local.replace("-","_")
                self.outk(name)
            else:
                self.do(op)
        else:
            self.do(op)

        self.outk("(")
        self.do(obj.args.the)
        self.outk(")")
Пример #4
0
 def iri(self, text):
     # errrrr, duplicating stuff already in qname, yes?
     try:
         (long, local) = qname.uri_split(text)
     except qname.Unsplitable:
         long = ""
         local = text
     short = self.nsmap.getShort(long)
     if short != "rif":
         short = self.atom_prefix + short
     # self.outk(short+":"+atom_quote(local))
     if short == "":
         local = local.lower()  # hack...
         self.outk(atom_quote(local))
     else:
         self.outk(atom_quote(short + "_" + local))
Пример #5
0
 def handle_builtin_atom(self, obj):
     pred = obj.op.the.value.the
     if pred.datatype == rifns+"iri":
         (ns, local) = qname.uri_split(pred.lexrep)
         if ns == rif_bip:
             arg = obj.args.the.items
             method_name = "builtin_"+local.replace("-","_")
             debug('prolog-bi', 'looking for pred ', method_name)
             attr = getattr(self, method_name, None)
             if attr:
                 attr(*arg)
             else:
                 self.outk(method_name)
                 self.outk("(")
                 self.do(obj.args.the)
                 self.outk(")")
             return
     raise MissingBuiltin  # it's not builtin