Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON-LD to guess_format() #1403

Merged

Conversation

ajnelson-nist
Copy link
Contributor

Now that the rdflib package provides the functionality formerly in the
package rdflib-jsonld, it would be helpful for the utility function
guess_format to recognize file extensions indicative of JSON-LD
content.

This patch adds recognition of two file extensions, preserving syntax of
the SUFFIX_FORMAT_MAP variable:

  • .json
  • .jsonld

The latter is in recognition of the IANA media type
application/ld+json reporting the .jsonld file extension.
References:
https://www.iana.org/assignments/media-types/application/ld+json
via https://www.iana.org/assignments/media-types/media-types.xhtml
via https://w3c.github.io/json-ld-syntax/#iana-considerations

Signed-off-by: Alex Nelson alexander.nelson@nist.gov

Proposed Changes

  • Add "json" and "json-ld" to recognized extensions
  • Add "json" example to docstring for guess_format

Now that the `rdflib` package provides the functionality formerly in the
package `rdflib-jsonld`, it would be helpful for the utility function
`guess_format` to recognize file extensions indicative of JSON-LD
content.

This patch adds recognition of two file extensions, preserving syntax of
the `SUFFIX_FORMAT_MAP` variable:
* `.json`
* `.jsonld`

The latter is in recognition of the IANA media type
`application/ld+json` reporting the `.jsonld` file extension.
References:
https://www.iana.org/assignments/media-types/application/ld+json
via https://www.iana.org/assignments/media-types/media-types.xhtml
via https://w3c.github.io/json-ld-syntax/#iana-considerations

Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
@nicholascar
Copy link
Member

Good update. Happy to merge.

Though this is simple, please next time add a test too, even if trivial? Thanks!

@nicholascar nicholascar merged commit fd935e2 into RDFLib:master Sep 10, 2021
@ajnelson-nist
Copy link
Contributor Author

Ah, I apologize, I had delegated the test to the docstring, thinking a docstrings test would pick it up.

I think I see where to add the test now. I'll add a follow-on PR.

@ajnelson-nist ajnelson-nist deleted the add-json-ld-to-guess-format branch September 28, 2021 20:46
ajnelson-nist added a commit to casework/CASE-Utilities-Python that referenced this pull request Sep 28, 2021
rdflib 6.0.1 upgraded `guess_format()` to report JSON-LD (via PRs 1403
and 1408).  With the functionality upstream, this patch moves towards
completing tech. transfer by deprecating the local implementation.

References:
* RDFLib/rdflib#1403
* RDFLib/rdflib#1408

Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants