graph.py 530 B

12345678910111213141516
  1. from __future__ import annotations
  2. from typing import IO, Optional
  3. from rdflib.graph import Graph
  4. from rdflib.query import Result, ResultParser
  5. class GraphResultParser(ResultParser):
  6. # type error: Signature of "parse" incompatible with supertype "ResultParser"
  7. def parse(self, source: IO, content_type: Optional[str]) -> Result: # type: ignore[override]
  8. res = Result("CONSTRUCT") # hmm - or describe?type_)
  9. res.graph = Graph()
  10. res.graph.parse(source, format=content_type)
  11. return res