home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / python-support / python2.6 / rdflib / syntax / parsers / N3Parser.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  3.0 KB  |  55 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from rdflib import URIRef, BNode, Literal, RDF, Variable
  5. from rdflib.util import from_n3
  6. from rdflib.syntax.parsers import Parser
  7. from rdflib.syntax.parsers.n3p.n3proc import N3Processor
  8. from rdflib.Graph import Graph, QuotedGraph, ConjunctiveGraph
  9.  
  10. class N3Parser(Parser):
  11.     
  12.     def __init__(self):
  13.         pass
  14.  
  15.     
  16.     def parse(self, source, graph):
  17.         if not graph.store.context_aware:
  18.             raise AssertionError
  19.         if not graph.store.formula_aware:
  20.             raise AssertionError
  21.         conj_graph = ConjunctiveGraph(store = graph.store)
  22.         conj_graph.default_context = graph
  23.         sink = Sink(conj_graph)
  24.         if not source.getPublicId() and source.getSystemId():
  25.             pass
  26.         baseURI = graph.absolutize('')
  27.         p = N3Processor('nowhere', sink, baseURI = baseURI)
  28.         p.userkeys = True
  29.         p.data = source.getByteStream().read()
  30.         p.parse()
  31.         for prefix, namespace in p.bindings.items():
  32.             conj_graph.bind(prefix, namespace)
  33.         
  34.  
  35.  
  36.  
  37. class Sink(object):
  38.     
  39.     def __init__(self, graph):
  40.         self.graph = graph
  41.  
  42.     
  43.     def start(self, root):
  44.         pass
  45.  
  46.     
  47.     def statement(self, s, p, o, f):
  48.         f.add((s, p, o))
  49.  
  50.     
  51.     def quantify(self, formula, var):
  52.         pass
  53.  
  54.  
  55.