parser
Parser plugin interface.
This module defines the parser plugin interface and contains other related parser support code.
The module is mainly useful for those wanting to write a parser that can plugin to rdflib. If you are wanting to invoke a parser you likely want to do so through the Graph class parse method.
Classes:
-
FileInputSource– -
InputSource–TODO:
-
Parser– -
PythonInputSource–Constructs an RDFLib Parser InputSource from a Python data structure,
-
StringInputSource–Constructs an RDFLib Parser InputSource from a Python String or Bytes
-
URLInputSource–Constructs an RDFLib Parser InputSource from a URL to read it from the Web.
__all__
module-attribute
__all__ = ['Parser', 'InputSource', 'StringInputSource', 'URLInputSource', 'FileInputSource', 'PythonInputSource']
headers
module-attribute
BytesIOWrapper
Bases: BufferedIOBase
Methods:
-
close– -
fileno– -
flush– -
isatty– -
read–Read at most size bytes, returned as a bytes object.
-
read1–Read at most size bytes, with at most one call to the underlying raw stream’s
-
readable– -
readinto–Read len(b) bytes into buffer b.
-
readinto1–Read len(b) bytes into buffer b, with at most one call to the underlying raw
-
seek– -
seekable– -
tell– -
truncate– -
writable– -
write–
Attributes:
-
__slots__– -
closed(bool) – -
enc_str(Optional[Union[BytesIO, BufferedIOBase]]) – -
encoder– -
encoding– -
has_read1(Optional[bool]) – -
has_seek(Optional[bool]) – -
name(Any) – -
text_str(Optional[Union[StringIO, TextIOBase]]) – -
wrapped–
Source code in rdflib/parser.py
__slots__
class-attribute
instance-attribute
__slots__ = ('wrapped', 'enc_str', 'text_str', 'encoding', 'encoder', 'has_read1', 'has_seek', '_name', '_fileno', '_isatty', '_leftover', '_bytes_per_char', '_text_bytes_offset')
close
Source code in rdflib/parser.py
fileno
flush
isatty
read
Read at most size bytes, returned as a bytes object.
If the size argument is negative or omitted read until EOF is reached. Return an empty bytes object if already at EOF.
Source code in rdflib/parser.py
read1
Read at most size bytes, with at most one call to the underlying raw stream’s read() or readinto() method. Returned as a bytes object.
If the size argument is negative or omitted, read until EOF is reached. Return an empty bytes object at EOF.
Source code in rdflib/parser.py
readable
readinto
Read len(b) bytes into buffer b.
Returns number of bytes read (0 for EOF), or error if the object is set not to block and has no data to read.
Source code in rdflib/parser.py
readinto1
Read len(b) bytes into buffer b, with at most one call to the underlying raw stream’s read() or readinto() method.
Returns number of bytes read (0 for EOF), or error if the object is set not to block and has no data to read.
Source code in rdflib/parser.py
seek
Source code in rdflib/parser.py
seekable
tell
Source code in rdflib/parser.py
truncate
writable
FileInputSource
FileInputSource(file: Union[BinaryIO, TextIO, TextIOBase, RawIOBase, BufferedIOBase], /, encoding: Optional[str] = None)
Bases: InputSource
Methods:
-
__repr__–
Attributes:
-
file–
Source code in rdflib/parser.py
InputSource
Bases: InputSource
TODO:
Methods:
-
close–
Attributes:
-
auto_close– -
content_type(Optional[str]) –
Source code in rdflib/parser.py
close
Parser
PythonInputSource
Bases: InputSource
Constructs an RDFLib Parser InputSource from a Python data structure, for example, loaded from JSON with json.load or json.loads:
import json as_string = “”“{ … “@context” : {“ex” : “http://example.com/ns#”}, … “@graph”: [{“@type”: “ex:item”, “@id”: “#example”}] … }”“” as_python = json.loads(as_string) source = create_input_source(data=as_python) isinstance(source, PythonInputSource) True
Methods:
-
close– -
getPublicId– -
getSystemId– -
setPublicId– -
setSystemId–
Attributes:
-
auto_close– -
content_type– -
data– -
public_id(Optional[str]) – -
system_id(Optional[str]) –
Source code in rdflib/parser.py
close
getPublicId
getSystemId
setPublicId
StringInputSource
StringInputSource(value: Union[str, bytes], encoding: str = 'utf-8', system_id: Optional[str] = None)
Bases: InputSource
Constructs an RDFLib Parser InputSource from a Python String or Bytes
Source code in rdflib/parser.py
URLInputSource
Bases: InputSource
Constructs an RDFLib Parser InputSource from a URL to read it from the Web.
Methods:
Attributes:
-
content_type– -
links(List[str]) – -
response_info– -
url–
Source code in rdflib/parser.py
__repr__
get_alternates
Source code in rdflib/parser.py
get_links
classmethod
Source code in rdflib/parser.py
getallmatchingheaders
classmethod
Source code in rdflib/parser.py
create_input_source
create_input_source(source: Optional[Union[IO[bytes], TextIO, InputSource, str, bytes, PurePath]] = None, publicID: Optional[str] = None, location: Optional[str] = None, file: Optional[Union[BinaryIO, TextIO]] = None, data: Optional[Union[str, bytes, dict]] = None, format: Optional[str] = None) -> InputSource
Return an appropriate InputSource instance for the given parameters.
Source code in rdflib/parser.py
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 | |