#!/usr/bin/env python2.5 import cgitb cgitb.enable() import sys, os sys.path = ['..', '../trio'] + sys.path from trio import Graph, n3 n3.prefix('', 'http://purl.org/ns/meteo#') place = os.environ.get('PATH_INFO')[1:] uri = 'http://infomesh.net/forecast/%s.rdf' % place print 'Content-Type: text/plain' print G = Graph(uri, format='rdfxml') Q = n3("""[ :time ?time; :cloudCover [ :percent ?cloud ]; :temperature [ :celsius ?temperature ]; :precipitation [ :inches ?precipitation ] ] .""") v = lambda term: term.lexical for i, b in enumerate(G.select(Q, order='time')): if i >= 50: break print v(b.time), v(b.temperature), v(b.cloud), v(b.precipitation) # EOF