Example #1
0
    def visit_sparqlclause(self, sparqlclause, **kw):
        def do_bindparam(m):
            name = m.group(1)
            if name in sparqlclause._bindparams:
                self.process(sparqlclause._bindparams[name], **kw)
            return '??'

        # un-escape any \:params
        text = BIND_PARAMS_ESC.sub(
            lambda m: m.group(1),
            BIND_PARAMS.sub(do_bindparam,
                            self.post_process_text(sparqlclause.text)))
        if sparqlclause.quad_storage:
            text = 'define input:storage %s %s' % (sparqlclause.quad_storage,
                                                   text)
        return 'SPARQL ' + text
Example #2
0
    def visit_sparqlclause(self, sparqlclause, **kw):
        def do_bindparam(m):
            name = m.group(1)
            if name in sparqlclause._bindparams:
                self.process(sparqlclause._bindparams[name], **kw)
            return '??'

        # un-escape any \:params
        text = BIND_PARAMS_ESC.sub(
            lambda m: m.group(1),
            BIND_PARAMS.sub(
                do_bindparam,
                self.post_process_text(sparqlclause.text))
        )
        if sparqlclause.quad_storage:
            text = 'define input:storage %s %s' % (
                sparqlclause.quad_storage, text)
        return 'SPARQL ' + text
Example #3
0
    def visit_textclause(self, textclause, **kw):
        def do_bindparam(m):
            name = m.group(1)
            if name in textclause._bindparams:
                return self.process(textclause._bindparams[name], **kw)
            else:
                return self.bindparam_string(name, **kw)

        if not self.stack:
            self.isplaintext = True

        if len(textclause._bindparams) == 0:
            # Prevents double escaping of percent character
            return textclause.text
        else:
            # un-escape any \:params
            return BIND_PARAMS_ESC.sub(
                lambda m: m.group(1),
                BIND_PARAMS.sub(do_bindparam,
                                self.post_process_text(textclause.text)))