Mercurial > code > home > repos > gcalendarwatch
view graphconvert.py @ 36:cb990883e52f
deployment; dep updates
author | drewp@bigasterisk.com |
---|---|
date | Sun, 12 Nov 2023 23:19:23 -0800 |
parents | e2209226b001 |
children | 7d9609edcf9c |
line wrap: on
line source
from rdflib import RDF, ConjunctiveGraph, Literal, Namespace, URIRef EV = Namespace("http://bigasterisk.com/event#") def asGraph(events, extraClasses=[], ctx=EV['gcalendar']): graph = ConjunctiveGraph() graph.namespace_manager.bind('ev', EV) for ev in events: uri = URIRef(ev['uri']) def add(p, o): return graph.add((uri, p, o, ctx)) add(RDF.type, EV['Event']) for cls in extraClasses: add(RDF.type, cls) add(EV['title'], Literal(ev['title'])) add(EV['start'], Literal(ev['start'])) add(EV['startDate'], Literal(ev['startDate'])) add(EV['end'], Literal(ev['end'])) add(EV['feed'], URIRef(ev['feed'])) # graph.add((feed, RDFS.label, Literal(ev['feedTitle']))) if 'htmlLink' in ev: add(EV['htmlLink'], URIRef(ev['htmlLink'])) return graph