def update(self, ctx): request = inevow.IRequest(ctx) graph = Graph() graph.parse("passwd.n3", format="n3") g = lambda pred: graph.value(TT['okjUpdate'], pred) if ((request.getUser(), request.getPassword()) == (g(TT['user']), g(TT['password']))): graph = getGraph() addTrainsAtStation(graph, STATION['OKJ'], literalToday()) return "update ok" else: request.setHeader('WWW-Authenticate', 'Basic realm="traintimes"') request.setResponseCode(http.UNAUTHORIZED) return "Authentication required."
Literal("times for train %s at %s on %s" % (graph.label(train), graph.label(station), searchDate)))) return ctxURI def addTrainsAtStation(graph, station, searchDate): for train in graph.objects(station, TT['normalTrain']): #if '11' not in train: # continue sub = addTrainInfo(graph, train, searchDate, station) writeSubgraph(graph.get_context(sub)) if __name__ == '__main__': graph = getGraph() searchDate = literalToday() if 1: addTrainsAtStation(graph, STATION['OKJ'], searchDate) f = open("/tmp/gr.nt", "w") graph.serialize(f, format="nt") else: graph.parse(open("/tmp/gr.nt"), format="nt") #print addTrainInfo(graph, TRAIN['n547'], searchDate, STATION['OKJ']) #print graph.serialize(format="n3") #print trainsToday(graph, searchDate, STATION['OKJ'])
graph.label(station), searchDate)))) return ctxURI def addTrainsAtStation(graph, station, searchDate): for train in graph.objects(station, TT['normalTrain']): #if '11' not in train: # continue sub = addTrainInfo(graph, train, searchDate, station) writeSubgraph(graph.get_context(sub)) if __name__ == '__main__': graph = getGraph() searchDate = literalToday() if 1: addTrainsAtStation(graph, STATION['OKJ'], searchDate) f = open("/tmp/gr.nt", "w") graph.serialize(f, format="nt") else: graph.parse(open("/tmp/gr.nt"), format="nt") #print addTrainInfo(graph, TRAIN['n547'], searchDate, STATION['OKJ']) #print graph.serialize(format="n3") #print trainsToday(graph, searchDate, STATION['OKJ'])