Skip to content

Commit ce43114

Browse files
committed
Bump rdflib dependency to 6.0.1, deprecating local guess_format
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>
1 parent d8be3d2 commit ce43114

File tree

3 files changed

+5
-27
lines changed

3 files changed

+5
-27
lines changed

case_utils/__init__.py

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,13 @@
1313

1414
__version__ = "0.2.1"
1515

16+
import warnings
17+
1618
import rdflib.util
1719

1820
from . import local_uuid
1921

2022
def guess_format(fpath, fmap=None):
21-
"""
22-
This function is a wrapper around rdflib.util.guess_format(), adding that the .json extension should be recognized as JSON-LD.
23-
24-
:param fpath: File path.
25-
:type fpath: string
26-
27-
:param fmap: Mapper dictionary; see rdflib.util.guess_format() for further description. Note that as in rdflib 5.0.0, supplying this argument overwrites, not augments, the suffix format map used by rdflib.
28-
:type fmap: dict
29-
30-
:returns: RDF file format, fit for rdflib.Graph.parse() or .serialize(); or, None if file extension not mapped.
31-
:rtype: string
32-
"""
33-
34-
assert fmap is None or isinstance(fmap, dict), "Type check failed"
35-
36-
if fmap is None:
37-
updated_fmap = {key:rdflib.util.SUFFIX_FORMAT_MAP[key] for key in rdflib.util.SUFFIX_FORMAT_MAP}
38-
if not "json" in updated_fmap:
39-
updated_fmap["json"] = "json-ld"
40-
if not "jsonld" in updated_fmap:
41-
updated_fmap["jsonld"] = "json-ld"
42-
else:
43-
updated_fmap = {k:fmap[k] for k in fmap}
23+
warnings.warn("The functionality in case_utils.guess_format is now upstream. Please revise your code to use rdflib.util.guess_format. The function arguments remain the same. case_utils.guess_format will be removed in case_utils 0.4.0.", DeprecationWarning)
4424

45-
return rdflib.util.guess_format(fpath, updated_fmap)
25+
return rdflib.util.guess_format(fpath, fmap)

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ classifiers =
2020
install_requires =
2121
pandas
2222
pyparsing < 3.0.0
23-
rdflib >= 6.0.0
23+
rdflib >= 6.0.1
2424
requests
2525
tabulate
2626
packages = find:

tests/case_utils/test_guess_format.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ def test_rdflib_util_guess_format_ttl_default():
3838
def test_rdflib_util_guess_format_ttl_fmap():
3939
assert rdflib.util.guess_format(PATH_TO_TTL, FMAP_XHTML_GRDDL) == "turtle", "Failed to recognize .ttl RDF file extension when using fmap"
4040

41-
@pytest.mark.xfail(reason="rdflib 5.0.0 known to not recognize .json", strict=True)
4241
def test_rdflib_util_guess_format_json():
4342
assert rdflib.util.guess_format(PATH_TO_JSON) == "json-ld", "Failed to recognize .json RDF file extension"
4443

45-
@pytest.mark.xfail(reason="rdflib 5.0.0 known to not recognize .jsonld", strict=True)
4644
def test_rdflib_util_guess_format_jsonld():
4745
assert rdflib.util.guess_format(PATH_TO_JSONLD) == "json-ld", "Failed to recognize .jsonld RDF file extension"
4846

0 commit comments

Comments
 (0)