from swap import llyn, diag, notation3, RDFSink, uripath, myStore from swap.diag import verbosity, setVerbosity, progress # from swap.uripath import join from swap.notation3 import RDF_NS_URI from swap.myStore import store, load, loadMany, Namespace import swap.llyn #import uripath global yearInQuestion, startDate, endDate import string import sys qu = Namespace("http://www.w3.org/2000/10/swap/pim/qif#") tax = Namespace("http://www.w3.org/2000/10/swap/pim/tax.n3#") rdf = Namespace(RDF_NS_URI) rdfs = Namespace("http://www.w3.org/2000/01/rdf-schema#") trip = Namespace("http://www.w3.org/ns/pim/trip#") cat_ns = Namespace("../../../Financial/Data/categories.n3#") owl = Namespace("http://www.w3.org/2002/07/owl#") monthName = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] rdf_type = rdf.type # cat = cat_ns kb = None
import webAccess, uripath, llyn, myStore, term, diag from myStore import load, Namespace from term import Literal from diag import progress, chatty_flag from set_importer import Set #diag.chatty_flag=0 # Standard python import sys, getopt from sys import exit, stderr from time import clock import re from codecs import utf_8_encode BNF = Namespace("http://www.w3.org/2000/10/swap/grammar/bnf#") RDF = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#") branchTable = {} tokenSet = Set() class tokenHolder(object): def __init__(self): self.tok = None def __call__(self, val=123): if val != 123: self.tok = val return self return self.tok
""" __version__ = '$Id$' from string import maketrans, translate from swap.myStore import Namespace, load, setStore # http://www.w3.org/2000/10/swap/ from swap.RDFSink import LITERAL_DT #hmm... generate from schema? from fromIcal import iCalendarDefs # http://www.w3.org/2002/12/cal/ CRLF = chr(13) + chr(10) RDF = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#") # ICAL = Namespace('http://www.w3.org/2002/12/cal/icaltzd#') ICAL = Namespace('http://www.w3.org/2002/12/cal/ical#') XMLSchema = Namespace('http://www.w3.org/2001/XMLSchema#') class CalWr: def __init__(self, writeFun): self._w = writeFun self.floatTZ = None # timezone for floating times def export(self, sts, addr): """export calendar objects from an RDF graph in iCalendar syntax """ for cal in sts.each(pred=RDF.type, obj=ICAL.Vcalendar):
sys.path.append('/home/syosi/SWAP/grammar') import sparql_tokens import time try: from swap import webAccess, uripath, llyn, myStore, term, diag from swap.myStore import load, Namespace from swap.term import Literal from swap.diag import progress, chatty_flag except ImportError: import webAccess, uripath, llyn, myStore, term, diag from myStore import load, Namespace from term import Literal from diag import progress, chatty_flag BNF = Namespace("http://www.w3.org/2000/10/swap/grammar/bnf#") class Rule(object): def __init__(self, lhs, rhs): self.lhs = lhs self.rhs = rhs def __getitem__(self, i): if i == len(self.rhs): return None return self.rhs[i] def __len__(self): return len(self.rhs)
from swap import llyn, diag, notation3, RDFSink, uripath, myStore from swap.diag import verbosity, setVerbosity, progress # from swap.uripath import join from swap.notation3 import RDF_NS_URI from swap.myStore import store, load, loadMany, Namespace import swap.llyn global yearInQuestion, startDate, endDate import string, time, sys from sys import stderr from time import gmtime, mktime from math import log, exp OFX = Namespace('http://www.w3.org/2000/10/swap/pim/ofx#') qu = Namespace("http://www.w3.org/2000/10/swap/pim/qif#") rdf = Namespace(RDF_NS_URI) rdfs = Namespace("http://www.w3.org/2000/01/rdf-schema#") cur = Namespace("http://www.w3.org/2007/ont/currency#") # cat = Namespace("categories.n3#") info = lambda s: sys.stderr.write(s + '\n') monthName = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] currencySource = uripath.join(uripath.base(), "currencies.n3")
__version__ = '$Id: check.py,v 1.62 2009-12-17 06:59:36 connolly Exp $'[1:-1] # mystore and term should be swappable with rdflib; shared interfaces from swap.myStore import load, Namespace, formula #@@get rid of the global store from swap.RDFSink import PRED, SUBJ, OBJ #@@ this is the old quad API; should go. from swap.set_importer import Set # which python version shall we support? from swap.term import List, Literal, CompoundTerm, BuiltIn, Function #@@ TODO: split built-ins out of swap.term. don't rely on interning at the interface from swap.llyn import Formula #@@ dependency should not be be necessary from swap.diag import verbosity, setVerbosity, progress from swap import diag from swap.query import testIncludes #see also http://en.wikipedia.org/wiki/Unification . Currently cwm's unification algorithm is spread all over the place. import swap.llyn # Chosen engine registers itself import sys # to get exception info for diagnostics reason = Namespace("http://www.w3.org/2000/10/swap/reason#") log = Namespace("http://www.w3.org/2000/10/swap/log#") rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#") rei = Namespace("http://www.w3.org/2004/06/rei#") chatty = 0 debugLevelForInference = 000 debugLevelForParsing = 0 nameBlankNodes = 0 proofSteps = 0 knownReasons = Set([ reason.Premise, reason.Parsing, reason.Inference, reason.Conjunction, reason.Fact, reason.Extraction, reason.CommandLine, reason.Conclusion ])
except ImportError: import llyn, diag from myStore import loadMany from diag import verbosity, setVerbosity, progress import notation3 # N3 parsers and generators from RDFSink import FORMULA, LITERAL, ANONYMOUS, Logic_NS import uripath from uripath import base from myStore import Namespace import myStore from notation3 import RDF_NS_URI from llyn import Formula, CONTEXT, PRED, SUBJ, OBJ #daml = Namespace("http://www.daml.org/2001/03/daml+oil#") OWL = Namespace("http://www.w3.org/2002/07/owl#") RDF = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#") LOG = Namespace("http://www.w3.org/2000/10/swap/log#") DELTA = Namespace("http://www.w3.org/2004/delta#") def debugBnode(n, f): progress("For node %s" % ` n `) for s in f.statementsMatching(subj=n): progress(" %s %s; # could be ifp?" % ( ` s.predicate() `, ` s.object() `)) for s in f.statementsMatching(obj=n): progress(" is %s of %s; # could be fp?" % ( ` s.predicate() `, ` s.subject() `))
class Usage(Exception): """python rdf2dot.py foo.rdf > foo.dot """ def __init__(self, msg): self._msg = msg def __str__(self): return "%s\nUsage: %s" % (self._msg, self.__doc__) import sys, os from swap.myStore import load, Namespace GV = Namespace('http://www.w3.org/2001/02pd/gv#') RDF = Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#') RCSId = '$Id: rdf2dot.py,v 1.8 2007-06-26 02:36:15 syosi Exp $' def dotTop(text): text("/* transformed by %s */\n" % RCSId) EdgeAttributes = ( GV.label, GV.color, GV.shape, GV.style, GV.fontcolor,
#import swap from swap.myStore import Namespace, formula, symbol, intern, bind from swap.diag import progress from swap import uripath from swap.uripath import join, base from swap.notation3 import RDF_NS_URI import swap.notation3 # N3 parsers and generators from swap import isodate # for isodate.fullString # import toXML # RDF generator # PyGarmon http://pygarmin.sourceforge.net/ from garmin import Win32SerialLink, Garmin, UnixSerialLink, degrees, TimeEpoch, \ TrackHdr RDF = Namespace(RDF_NS_URI) # RDFS = Namespace("http://www.w3.org/2000/01/rdf-schema#") GPS = Namespace("http://www.w3.org/ns/pim/gpx#") bind("gps", "http://www.w3.org/ns/pim/gpx#") # Suggest as prefix in RDF file WGS = Namespace("http://www.w3.org/2003/01/geo/wgs84_pos#") bind("wgs84", "http://www.w3.org/2003/01/geo/wgs84_pos#") monthName = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] rdf_type = RDF.type ######### Get GPS Data
from swap.diag import progress from swap import uripath from swap.uripath import join, base from swap.notation3 import RDF_NS_URI import swap.notation3 # N3 parsers and generators from swap import isodate # for isodate.fullString # import toXML # RDF generator # PyGarmon http://pygarmin.sourceforge.net/ from garmin import Win32SerialLink, Garmin, UnixSerialLink, degrees, TimeEpoch, \ TrackHdr RDF = Namespace(RDF_NS_URI) # RDFS = Namespace("http://www.w3.org/2000/01/rdf-schema#") GPS = Namespace("http://hackdiary.com/ns/gps#") bind("gps", "http://hackdiary.com/ns/gps#") # Suggest as prefix in RDF file WGS = Namespace("http://www.w3.org/2003/01/geo/wgs84_pos#") bind("wgs84", "http://www.w3.org/2003/01/geo/wgs84_pos#") monthName= ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] rdf_type = RDF.type ######### Get GPS Data def doCommand(serialDevice=None, outputURI=None, doTracks=1, doWaypoints=1, verbose=0):
""" from os import system, popen3 import os import sys import urllib # From PYTHONPATH equivalent to http://www.w3.org/2000/10 from swap import llyn from swap.myStore import load, loadMany, Namespace from swap.uripath import refTo, base from swap import diag from swap.diag import progress from swap.term import AnonymousNode rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#") test = Namespace("http://www.w3.org/2000/10/swap/test.n3#") n3test = Namespace("http://www.w3.org/2004/11/n3test#") rdft = Namespace("http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#") triage = Namespace("http://www.w3.org/2000/10/swap/test/triage#") sparql_manifest = Namespace( "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#") sparql_query = Namespace( "http://www.w3.org/2001/sw/DataAccess/tests/test-query#") dawg_test = Namespace("http://www.w3.org/2001/sw/DataAccess/tests/test-dawg#") import getopt import sys import re
from swap.myStore import Namespace, formula, symbol, intern, bind, load from swap.diag import progress #import uripath from swap.uripath import refTo, base from swap.notation3 import RDF_NS_URI import swap.notation3 # N3 parsers and generators from swap import isodate # for isodate.fullString # import toXML # RDF generator # PyGarmon http://www #from garmin import Win32SerialLink, Garmin, UnixSerialLink, degrees, TimeEpoch, \ # TrackHdr RDF = Namespace(RDF_NS_URI) # RDFS = Namespace("http://www.w3.org/2000/01/rdf-schema#") GPS = Namespace("http://www.w3.org/ns/pim/gpx#") bind("gps", "http://www.w3.org/ns/pim/gpx#") # Suggest as prefix in RDF file WGS = Namespace("http://www.w3.org/2003/01/geo/wgs84_pos#") bind("wgs84", "http://www.w3.org/2003/01/geo/wgs84_pos#") EXIF = Namespace("http://www.w3.org/2000/10/swap/pim/exif#") FILE = Namespace("http://www.w3.org/2000/10/swap/pim/file#") monthName = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] rdf_type = RDF.type
os.chdir('..') swap = os.getcwd() os.chdir(realcwd) os.environ['SWAP'] = swap # From PYTHONPATH equivalent to http://www.w3.org/2000/10 from swap import llyn from swap.myStore import load, loadMany, Namespace, formula from swap.uripath import refTo, base, join from swap import diag from swap.diag import progress from swap.notation3 import ToN3 rdf = Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#") rdfs = Namespace("http://www.w3.org/2000/01/rdf-schema#") xsd = Namespace("http://www.w3.org/2001/XMLSchema#") owl = Namespace("http://www.w3.org/2002/07/owl#") test = Namespace("http://www.w3.org/2000/10/swap/test.n3#") n3test = Namespace("http://www.w3.org/2004/11/n3test#") rdft = Namespace("http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#") triage = Namespace("http://www.w3.org/2000/10/swap/test/triage#") mf = Namespace("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#") qt = Namespace("http://www.w3.org/2001/sw/DataAccess/tests/test-query#") import getopt import sys import re from htmlentitydefs import codepoint2name import md5, binascii