linked-data-python 0.6.3__tar.gz → 0.6.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/PKG-INFO +1 -1
  2. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/transpiler/core.py +16 -1
  3. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/linked_data_python.egg-info/PKG-INFO +1 -1
  4. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/pyproject.toml +1 -1
  5. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_prefix_scoping.py +21 -0
  6. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/LICENSE.md +0 -0
  7. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/README.md +0 -0
  8. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/__init__.py +0 -0
  9. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/__main__.py +0 -0
  10. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/backend.py +0 -0
  11. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/build.py +0 -0
  12. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/console.py +0 -0
  13. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/debug.py +0 -0
  14. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/formatter.py +0 -0
  15. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/importer.py +0 -0
  16. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/lsp/__init__.py +0 -0
  17. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/lsp/__main__.py +0 -0
  18. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/lsp/backend.py +0 -0
  19. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/lsp/hover.py +0 -0
  20. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/lsp/islanddoc.py +0 -0
  21. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/lsp/rpc.py +0 -0
  22. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/lsp/server.py +0 -0
  23. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/lsp/translate.py +0 -0
  24. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/pygments_lexer.py +0 -0
  25. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/runtime.py +0 -0
  26. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/sparql.py +0 -0
  27. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/transpiler/__init__.py +0 -0
  28. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/transpiler/errors.py +0 -0
  29. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/ldpy/transpiler/linemap.py +0 -0
  30. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/linked_data_python.egg-info/SOURCES.txt +0 -0
  31. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/linked_data_python.egg-info/dependency_links.txt +0 -0
  32. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/linked_data_python.egg-info/entry_points.txt +0 -0
  33. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/linked_data_python.egg-info/requires.txt +0 -0
  34. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/linked_data_python.egg-info/top_level.txt +0 -0
  35. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/setup.cfg +0 -0
  36. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_bench.py +0 -0
  37. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_bindings.py +0 -0
  38. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_build.py +0 -0
  39. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_call_suffix.py +0 -0
  40. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_charsets.py +0 -0
  41. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_coercion.py +0 -0
  42. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_console.py +0 -0
  43. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_current_graph.py +0 -0
  44. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_debug.py +0 -0
  45. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_debug_stepping.py +0 -0
  46. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_disambiguation.py +0 -0
  47. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_docs.py +0 -0
  48. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_docstrings.py +0 -0
  49. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_examples.py +0 -0
  50. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_formatter.py +0 -0
  51. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_generator.py +0 -0
  52. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_graphs.py +0 -0
  53. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_hover_parts.py +0 -0
  54. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_identity.py +0 -0
  55. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_import_hook.py +0 -0
  56. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_islanddoc.py +0 -0
  57. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_islands_terms.py +0 -0
  58. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_lexing.py +0 -0
  59. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_linemap.py +0 -0
  60. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_lsp_rpc.py +0 -0
  61. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_lsp_server.py +0 -0
  62. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_lsp_translate.py +0 -0
  63. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_match_island.py +0 -0
  64. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_micropython_subset.py +0 -0
  65. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_prefix_import.py +0 -0
  66. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_pygments_lexer.py +0 -0
  67. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_scope_modifiers.py +0 -0
  68. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_semantics.py +0 -0
  69. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_sourcemap_v3.py +0 -0
  70. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_sparql_expr.py +0 -0
  71. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_sparql_island.py +0 -0
  72. {linked_data_python-0.6.3 → linked_data_python-0.6.4}/tests/test_target_micropython.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: linked-data-python
3
- Version: 0.6.3
3
+ Version: 0.6.4
4
4
  Summary: Python extended with Semantic Web primitives: IRIs, RDF literals and Turtle-notation graphs as expressions, transpiled by island parsing.
5
5
  Author-email: Maxime Lefrançois <maxime.lefrancois@emse.fr>
6
6
  License: MIT
@@ -1392,6 +1392,10 @@ class Transpiler:
1392
1392
  self._take(j - self.i) # '@prefix p:' + blancs
1393
1393
  parts = self._take_firi_parts()
1394
1394
  self._g_ws()
1395
+ as_name, k = self._prefix_as_clause(self.i)
1396
+ if as_name:
1397
+ self._take(k - self.i)
1398
+ self._g_ws()
1395
1399
  if self._peek() != ".":
1396
1400
  self._error("'.' attendu pour clore la déclaration @prefix")
1397
1401
  self._take(1)
@@ -1411,6 +1415,11 @@ class Transpiler:
1411
1415
  scope_mode)
1412
1416
  gen = "__namespaces__[%r] = %s.Namespace(%r)" % (
1413
1417
  prefix, RUNTIME_ALIAS, resolved)
1418
+ if as_name:
1419
+ gen = "__namespaces__[%r] = %s = %s.Namespace(%r)" % (
1420
+ prefix, as_name, RUNTIME_ALIAS, resolved)
1421
+ if scope_mode:
1422
+ gen = "%s %s; %s" % (scope_mode, as_name, gen)
1414
1423
  else:
1415
1424
  # global/nonlocal : réutiliser la variable de la liaison cible si
1416
1425
  # elle est dynamique — c'est elle que les usages du dehors lisent
@@ -1424,8 +1433,14 @@ class Transpiler:
1424
1433
  gen = "%s = %s.Namespace(%s.firi(%s)); __namespaces__[%r] = %s" % (
1425
1434
  var, RUNTIME_ALIAS, RUNTIME_ALIAS,
1426
1435
  self._firi_args(parts), prefix, var)
1436
+ if as_name:
1437
+ # `as EX` on a DYNAMIC prefix binds the Namespace built from
1438
+ # the IRI resolved at that point — the same object the
1439
+ # prefix itself uses, so the two can never disagree.
1440
+ gen += "; %s = %s" % (as_name, var)
1427
1441
  if scope_mode:
1428
- gen = "%s %s; %s" % (scope_mode, var, gen)
1442
+ names = var if not as_name else "%s, %s" % (var, as_name)
1443
+ gen = "%s %s; %s" % (scope_mode, names, gen)
1429
1444
  self._end_island("prefix", mark, gen)
1430
1445
  return True
1431
1446
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: linked-data-python
3
- Version: 0.6.3
3
+ Version: 0.6.4
4
4
  Summary: Python extended with Semantic Web primitives: IRIs, RDF literals and Turtle-notation graphs as expressions, transpiled by island parsing.
5
5
  Author-email: Maxime Lefrançois <maxime.lefrancois@emse.fr>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "linked-data-python"
7
- version = "0.6.3"
7
+ version = "0.6.4"
8
8
  description = "Python extended with Semantic Web primitives: IRIs, RDF literals and Turtle-notation graphs as expressions, transpiled by island parsing."
9
9
  readme = "README.md"
10
10
  license = { text = "MIT" }
@@ -347,3 +347,24 @@ def test_a_prefix_named_as_something_is_not_an_as_clause(run):
347
347
  ns, _ = run("@prefix ex: <http://example.org/ns#> as assets .\n"
348
348
  "t = ex:Thing\n")
349
349
  assert str(ns["assets"]) == "http://example.org/ns#"
350
+
351
+
352
+ def test_as_works_on_a_dynamic_prefix_too(run):
353
+ """`@prefix p: f<…> as P .` — the form the corpus actually needed first.
354
+ Every IRI of the region that motivated `as` is computed at run time, so
355
+ `as` on the static form alone would not have covered its own use case."""
356
+ ns, _ = run("host = 'example.org'\n"
357
+ "@prefix dyn: f<http://{host}/ns#> as DYN .\n"
358
+ "a = DYN['x']\n"
359
+ "b = dyn:x\n")
360
+ assert str(ns["DYN"]) == "http://example.org/ns#"
361
+ assert ns["a"] == ns["b"]
362
+
363
+
364
+ def test_a_dynamic_as_name_follows_the_scope_modifier(run):
365
+ ns, _ = run("host = 'example.org'\n"
366
+ "def f():\n"
367
+ " global @prefix dyn: f<http://{host}/ns#> as DYN .\n"
368
+ "f()\n"
369
+ "seen = str(DYN)\n")
370
+ assert ns["seen"] == "http://example.org/ns#"