Skip to content

Commit

Permalink
Merge pull request #279 from RDFLib/29_1
Browse files Browse the repository at this point in the history
ensure load_from_source doesn't convert `None` identifier to a bad string
  • Loading branch information
ashleysommer authored Dec 16, 2024
2 parents 1f1b861 + f69044c commit fc7a57b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Python PEP 440 Versioning](https://www.python.org/d
## [Unreleased]
- Nothing yet

## [0.29.1] - 2024-12-16

### Added
- Two new basic examples in the Examples folder.
- "sparql_assert_datatype.py" shows how to use SPARQL-based Constraints to assert a datatype on a literal.
- "remote_sparql.py" shows how to use SparqlConnector store to validate data on a remote SPARQL endpoint.

### Fixed
- Fixed a bug where the `identifier` would become "None" (string) in the `load_from_source` function.
- Typos in the example Ontology files in the test suite.


## [0.29.0] - 2024-11-01

### Added
Expand Down Expand Up @@ -1201,7 +1213,8 @@ just leaves the files open. Now it is up to the command-line client to close the

- Initial version, limited functionality

[Unreleased]: https://github.com/RDFLib/pySHACL/compare/v0.29.0...HEAD
[Unreleased]: https://github.com/RDFLib/pySHACL/compare/v0.29.1...HEAD
[0.29.0]: https://github.com/RDFLib/pySHACL/compare/v0.29.0...v0.29.1
[0.29.0]: https://github.com/RDFLib/pySHACL/compare/v0.28.1...v0.29.0
[0.28.1]: https://github.com/RDFLib/pySHACL/compare/v0.28.0...v0.28.1
[0.28.0]: https://github.com/RDFLib/pySHACL/compare/v0.27.0...v0.28.0
Expand Down
14 changes: 8 additions & 6 deletions pyshacl/rdfutil/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,21 @@ def get_rdf_from_web(url: Union[rdflib.URIRef, str]):
# The BaseURI usually ends with a filename (eg, https://example.com/validators/shapes)
# BaseURI can sometimes end with a / if URIs are relative to a directory.
# You will rarely see a BaseURI with a # on the end.
# The PublicID is the Identifier of a Graph. It is the canonical name of the graph,
# regardless of its hosted location. It is used to refer to the graph in a Dataset
# The PublicID is a concept inherited from the XML specificaion
# RDFLib uses PublicID for the Identifier of a Graph. It is the canonical name of the graph,
# regardless of its hosted location. It is also used to refer to a Named Graph in a Dataset
# and this is the name referenced in the owl:imports [ schema:name <publicID> ] statement.
# PublicID is not found in the Turtle file, it is known outside the file only.
# PublicID can end with a / or a # if you want consistency with the graph's base prefix.
# Alternatively, PublicID may not have a symbol at the end.
# Note, PublicID is now called "Identifier" in the load_from_source function.


def load_from_source(
source: Union[GraphLike, BufferedIOBase, TextIOBase, str, bytes],
g: Optional[GraphLike] = None,
rdf_format: Optional[str] = None,
identifier: Optional[str] = None,
identifier: Optional[Union[rdflib.URIRef, str]] = None,
multigraph: bool = False,
do_owl_imports: Union[bool, int] = False,
import_chain: Optional[List[Union[rdflib.URIRef, str]]] = None,
Expand All @@ -146,8 +148,8 @@ def load_from_source(
:type rdf_format: str | None
:param multigraph:
:type multigraph: bool
:param identifier: formerly "public_id"
:type identifier: str | None
:param identifier: Identifier for the Named Graph being loaded. formerly "public_id"
:type identifier: str | URIRef | None
:param do_owl_imports:
:type do_owl_imports: bool|int
:param import_chain:
Expand All @@ -163,7 +165,7 @@ def load_from_source(
source_as_filename: Optional[str] = None
source_as_bytes: Optional[bytes] = None
filename = None
identifier = str(identifier) # This is our passed-in id (formerly public_id)
identifier = None if identifier is None else str(identifier) # This is our passed-in id (formerly public_id)
_maybe_id: Optional[str] = None # For default-graph identifier
base_uri: Optional[str] = None # Base URI for relative URIs
uri_prefix = None # URI Prefix to bind to public ID
Expand Down

0 comments on commit fc7a57b

Please sign in to comment.