@@ -1400,26 +1400,26 @@ def parse(
14001400 :doc:`Security Considerations </security_considerations>`
14011401 documentation.
14021402
1403- :Parameters:
1404-
1405- - ``source``: An InputSource, file-like object, or string. In the case
1406- of a string the string is the location of the source.
1407- - ``location``: A string indicating the relative or absolute URL of
1408- the source. Graph's absolutize method is used if a relative location
1403+ :param source: An `InputSource`, file-like object, `Path` like object,
1404+ or string. In the case of a string the string is the location of the
1405+ source.
1406+ :param location: A string indicating the relative or absolute URL of the
1407+ source. `Graph`'s absolutize method is used if a relative location
14091408 is specified.
1410- - `` file`` : A file-like object.
1411- - `` data`` : A string containing the data to be parsed.
1412- - `` format`` : Used if format can not be determined from source, e.g.
1409+ :param file: A file-like object.
1410+ :param data: A string containing the data to be parsed.
1411+ :param format: Used if format can not be determined from source, e.g.
14131412 file extension or Media Type. Defaults to text/turtle. Format
14141413 support can be extended with plugins, but "xml", "n3" (use for
14151414 turtle), "nt" & "trix" are built in.
1416- - `` publicID`` : the logical URI to use as the document base. If None
1415+ :param publicID: the logical URI to use as the document base. If None
14171416 specified the document location is used (at least in the case where
1418- there is a document location).
1419-
1420- :Returns:
1421-
1422- - self, the graph instance.
1417+ there is a document location). This is used as the base URI when
1418+ resolving relative URIs in the source document, as defined in `IETF
1419+ RFC 3986
1420+ <https://datatracker.ietf.org/doc/html/rfc3986#section-5.1.4>`_,
1421+ given the source document does not define a base URI.
1422+ :return: ``self``, i.e. the :class:`~rdflib.graph.Graph` instance.
14231423
14241424 Examples:
14251425
@@ -2206,15 +2206,18 @@ def parse(
22062206 ** args : Any ,
22072207 ) -> "Graph" :
22082208 """
2209- Parse source adding the resulting triples to its own context
2210- (sub graph of this graph).
2209+ Parse source adding the resulting triples to its own context (sub graph
2210+ of this graph).
22112211
22122212 See :meth:`rdflib.graph.Graph.parse` for documentation on arguments.
22132213
2214+ If the source is in a format that does not support named graphs it's triples
2215+ will be added to the default graph (i.e. `Dataset.default_context`).
2216+
22142217 :Returns:
22152218
2216- The graph into which the source was parsed. In the case of n3
2217- it returns the root context.
2219+ The graph into which the source was parsed. In the case of n3 it returns
2220+ the root context.
22182221
22192222 .. caution::
22202223
@@ -2228,6 +2231,14 @@ def parse(
22282231 For information on available security measures, see the RDFLib
22292232 :doc:`Security Considerations </security_considerations>`
22302233 documentation.
2234+
2235+ *Changed in 7.0*: The ``publicID`` argument is no longer used as the
2236+ identifier (i.e. name) of the default graph as was the case before
2237+ version 7.0. In the case of sources that do not support named graphs,
2238+ the ``publicID`` parameter will also not be used as the name for the
2239+ graph that the data is loaded into, and instead the triples from sources
2240+ that do not support named graphs will be loaded into the default graph
2241+ (i.e. `ConjunctionGraph.default_context`).
22312242 """
22322243
22332244 source = create_input_source (
@@ -2246,12 +2257,8 @@ def parse(
22462257 # create_input_source will ensure that publicId is not None, though it
22472258 # would be good if this guarantee was made more explicit i.e. by type
22482259 # hint on InputSource (TODO/FIXME).
2249- g_id : str = publicID and publicID or source .getPublicId ()
2250- if not isinstance (g_id , Node ):
2251- g_id = URIRef (g_id )
22522260
2253- context = Graph (store = self .store , identifier = g_id )
2254- context .remove ((None , None , None )) # hmm ?
2261+ context = self .default_context
22552262 context .parse (source , publicID = publicID , format = format , ** args )
22562263 # TODO: FIXME: This should not return context, but self.
22572264 return context
@@ -2459,6 +2466,14 @@ def parse(
24592466 ** args : Any ,
24602467 ) -> "Graph" :
24612468 """
2469+ Parse an RDF source adding the resulting triples to the Graph.
2470+
2471+ See :meth:`rdflib.graph.Graph.parse` for documentation on arguments.
2472+
2473+ The source is specified using one of source, location, file or data.
2474+
2475+ If the source is in a format that does not support named graphs it's triples
2476+ will be added to the default graph (i.e. `Dataset.default_context`).
24622477
24632478 .. caution::
24642479
@@ -2472,6 +2487,14 @@ def parse(
24722487 For information on available security measures, see the RDFLib
24732488 :doc:`Security Considerations </security_considerations>`
24742489 documentation.
2490+
2491+ *Changed in 7.0*: The ``publicID`` argument is no longer used as the
2492+ identifier (i.e. name) of the default graph as was the case before
2493+ version 7.0. In the case of sources that do not support named graphs,
2494+ the ``publicID`` parameter will also not be used as the name for the
2495+ graph that the data is loaded into, and instead the triples from sources
2496+ that do not support named graphs will be loaded into the default graph
2497+ (i.e. `ConjunctionGraph.default_context`).
24752498 """
24762499
24772500 c = ConjunctiveGraph .parse (
0 commit comments