A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/RDFLib/rdflib/commit/832e693 below:

JSON-LD context construction from a `dict` (#2306) · RDFLib/rdflib@832e693 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+22

-1

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+22

-1

lines changed Original file line number Diff line number Diff line change

@@ -421,13 +421,13 @@ def _prep_sources(

421 421

):

422 422

for source in inputs:

423 423

source_url = in_source_url

424 +

new_base = base

424 425

if isinstance(source, str):

425 426

source_url = source

426 427

source_doc_base = base or self.doc_base

427 428

new_ctx = self._fetch_context(

428 429

source, source_doc_base, referenced_contexts

429 430

)

430 -

new_base = base

431 431

if new_ctx is None:

432 432

continue

433 433

else:

Original file line number Diff line number Diff line change

@@ -3,6 +3,7 @@

3 3

"""

4 4 5 5

from functools import wraps

6 +

from pathlib import Path

6 7

from typing import Any, Dict

7 8 8 9

from rdflib.plugins.shared.jsonld import context, errors

@@ -213,3 +214,23 @@ def test_invalid_remote_context():

213 214

ctx_url = "http://example.org/recursive.jsonld"

214 215

SOURCES[ctx_url] = {"key": "value"}

215 216

ctx = Context(ctx_url)

217 + 218 + 219 +

def test_file_source(tmp_path: Path) -> None:

220 +

"""

221 +

A file URI source to `Context` gets processed correctly.

222 +

"""

223 +

file = tmp_path / "context.jsonld"

224 +

file.write_text(r"""{ "@context": { "ex": "http://example.com/" } }""")

225 +

ctx = Context(source=file.as_uri())

226 +

assert "http://example.com/" == ctx.terms["ex"].id

227 + 228 + 229 +

def test_dict_source(tmp_path: Path) -> None:

230 +

"""

231 +

A dictionary source to `Context` gets processed correctly.

232 +

"""

233 +

file = tmp_path / "context.jsonld"

234 +

file.write_text(r"""{ "@context": { "ex": "http://example.com/" } }""")

235 +

ctx = Context(source=[{"@context": file.as_uri()}])

236 +

assert "http://example.com/" == ctx.terms["ex"].id

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4