#!/usr/bin/python """Eep RDF API: Templating Thingy""" __author__ = 'Sean B. Palmer' __license__ = 'Copyright (C) 2001 Sean B. Palmer. GNU GPL 2' import eep, query def rule(ante, temp): return eep.parse(ante), temp def filter(r, store): """Give the results only - don't add to the store.""" qres, result = query.xtquery(r[0], store), [] for res in qres: x = r[1][:] for t in r[0]: t = t[:] for p in (0, 1, 2): if (t[p].type == 'Univar') and (t[p].repr in res[1].keys()): x = x.replace('(%s)' % t[p].repr, res[1][t[p].repr][1:-1].replace('<', '<')) result.append(x) return result def format(head, body, tail): r = '' for x in body: r+=x return head+r+tail def apply(rule, store, NTriples=0): for r in filter(rule, store): store.extend([x for x in r]) return [store, eep.serialize(store)][NTriples] if __name__=="__main__": print __doc__