changeset 7:9cf0859441f9

another rdf class for CountdownEvent records
author drewp@bigasterisk.com
date Mon, 03 Feb 2020 16:49:48 -0800
parents 9cface2e6b11
children 1e281ead081a
files gcalendarwatch
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/gcalendarwatch	Mon Feb 03 16:48:33 2020 -0800
+++ b/gcalendarwatch	Mon Feb 03 16:49:48 2020 -0800
@@ -98,16 +98,15 @@
     }
     return ret
 
-def asN3(events, conf):
-    return asGraph(events, conf).serialize(format='n3')
-
-def asGraph(events, conf):
+def asGraph(events, extraClasses=[]):
     graph = Graph()
     graph.namespace_manager.bind('ev', EV)
     for ev in events:
         uri = URIRef(ev['uri'])
         add = lambda p, o: graph.add((uri, p, o))
         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']))
@@ -232,9 +231,10 @@
         c = EV['gcalendar']
         currentRecords = list(currentRecords)
         self.agendaGraph.setToGraph(
-            [(s,p,o,c) for s,p,o in asGraph(limitDays(currentRecords, days=2), self.conf)])
+            [(s,p,o,c) for s,p,o in asGraph(limitDays(currentRecords, days=2))])
         self.countdownGraph.setToGraph(
-            [(s,p,o,c) for s,p,o in asGraph(filterStarred(currentRecords, maxCount=15), self.conf)])
+            [(s,p,o,c) for s,p,o in asGraph(filterStarred(currentRecords, maxCount=15),
+                                            extraClasses=[EV['CountdownEvent']])])
 
 
 class ReadMongoEvents(object):
@@ -313,7 +313,7 @@
             self.write(asJsonLd(self.settings.read.getEvents(t1, t2)))
         else:
             self.set_header("content-type", "text/n3")
-            self.write(asN3(self.settings.read.getEvents(t1, t2), self.settings.conf))
+            self.write(asGraph(self.settings.read.getEvents(t1, t2)).serialize(format='n3'))
 
 
 class Countdowns(cyclone.web.RequestHandler):