linked-data-python 0.5.1__py3-none-any.whl → 0.5.2__py3-none-any.whl
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.
- ldpy/console.py +13 -0
- ldpy/debug.py +24 -2
- ldpy/runtime.py +1 -3
- ldpy/transpiler/core.py +12 -8
- {linked_data_python-0.5.1.dist-info → linked_data_python-0.5.2.dist-info}/METADATA +1 -1
- {linked_data_python-0.5.1.dist-info → linked_data_python-0.5.2.dist-info}/RECORD +10 -10
- {linked_data_python-0.5.1.dist-info → linked_data_python-0.5.2.dist-info}/WHEEL +0 -0
- {linked_data_python-0.5.1.dist-info → linked_data_python-0.5.2.dist-info}/entry_points.txt +0 -0
- {linked_data_python-0.5.1.dist-info → linked_data_python-0.5.2.dist-info}/licenses/LICENSE.md +0 -0
- {linked_data_python-0.5.1.dist-info → linked_data_python-0.5.2.dist-info}/top_level.txt +0 -0
ldpy/console.py
CHANGED
|
@@ -70,6 +70,12 @@ class LdpyConsole(code.InteractiveConsole):
|
|
|
70
70
|
self._prefixes = dict(prefixes or {})
|
|
71
71
|
self._prefix_cols = {k: 0 for k in self._prefixes}
|
|
72
72
|
self._base = base
|
|
73
|
+
# The current graph and the current bindings are declarations too:
|
|
74
|
+
# like @prefix, a top-level @graph must survive to the next entry
|
|
75
|
+
# (otherwise `+{ ... }` after `@graph as g` sees no graph at all).
|
|
76
|
+
self._graph_var = None
|
|
77
|
+
self._bindings_var = None
|
|
78
|
+
self._counter = 0
|
|
73
79
|
|
|
74
80
|
def runsource(self, source, filename=None, symbol="single"):
|
|
75
81
|
"""Transpile then compile one entry; True = incomplete entry
|
|
@@ -79,6 +85,10 @@ class LdpyConsole(code.InteractiveConsole):
|
|
|
79
85
|
t.prefixes = dict(self._prefixes)
|
|
80
86
|
t._prefix_col = dict(self._prefix_cols)
|
|
81
87
|
t.base = self._base
|
|
88
|
+
t._graph_var = self._graph_var
|
|
89
|
+
t._bindings_var = self._bindings_var
|
|
90
|
+
# fresh names must not collide with those of the previous entries
|
|
91
|
+
t._ns_counter = self._counter
|
|
82
92
|
try:
|
|
83
93
|
result = t.run()
|
|
84
94
|
except LdpySyntaxError as e:
|
|
@@ -98,6 +108,9 @@ class LdpyConsole(code.InteractiveConsole):
|
|
|
98
108
|
self._prefixes = dict(t.prefixes)
|
|
99
109
|
self._prefix_cols = dict(t._prefix_col)
|
|
100
110
|
self._base = t.base
|
|
111
|
+
self._graph_var = t._graph_var
|
|
112
|
+
self._bindings_var = t._bindings_var
|
|
113
|
+
self._counter = t._ns_counter
|
|
101
114
|
for w in result.warnings:
|
|
102
115
|
self.write(str(w) + "\n")
|
|
103
116
|
self.runcode(code_obj)
|
ldpy/debug.py
CHANGED
|
@@ -92,11 +92,30 @@ def probe():
|
|
|
92
92
|
#: re-exported: debug tooling looks for them here (pure functions, defined
|
|
93
93
|
#: alongside the map in ldpy/transpiler/linemap.py)
|
|
94
94
|
__all__ = ["stepping_rules", "probe", "package_dir", "load_map",
|
|
95
|
+
"shadow_rel",
|
|
95
96
|
"translate_breakpoints", "translate_frames",
|
|
96
97
|
"snap_breakpoint_line", "snap_breakpoint_lines",
|
|
97
98
|
"run_direct", "main"]
|
|
98
99
|
|
|
99
100
|
|
|
101
|
+
def shadow_rel(source, root=None):
|
|
102
|
+
"""Path of the shadow inside the output directory.
|
|
103
|
+
|
|
104
|
+
Without a root, the basename: the shadow sits beside the source, and two
|
|
105
|
+
files never meet. With one — a workspace whose whole build is gathered in
|
|
106
|
+
a single directory — the tree is mirrored, which is what keeps `a/m.ldpy`
|
|
107
|
+
and `b/m.ldpy` from writing the same `m.py`. A source outside the root
|
|
108
|
+
falls back to its basename rather than climbing out of the output
|
|
109
|
+
directory with `../`."""
|
|
110
|
+
name = os.path.basename(source)
|
|
111
|
+
if not root:
|
|
112
|
+
return name
|
|
113
|
+
rel = os.path.relpath(os.path.abspath(source), os.path.abspath(root))
|
|
114
|
+
if rel.startswith(os.pardir + os.sep) or rel == os.pardir:
|
|
115
|
+
return name
|
|
116
|
+
return rel
|
|
117
|
+
|
|
118
|
+
|
|
100
119
|
def load_map(map_path):
|
|
101
120
|
"""Load a LanguageMap from a .ldpy.map file (JSON)."""
|
|
102
121
|
with open(map_path, "r", encoding="utf-8") as f:
|
|
@@ -167,6 +186,10 @@ def main(argv=None):
|
|
|
167
186
|
"straight in the .ldpy)")
|
|
168
187
|
parser.add_argument("-o", "--out", default=DEFAULT_OUT,
|
|
169
188
|
help="shadow directory (default: %(default)s)")
|
|
189
|
+
parser.add_argument("--root", metavar="DIR",
|
|
190
|
+
help="tree root the shadow mirrors: the .py is "
|
|
191
|
+
"written at OUT/<path of the source relative "
|
|
192
|
+
"to DIR> (default: OUT/<basename>)")
|
|
170
193
|
parser.add_argument("--listen", metavar="HOTE:PORT",
|
|
171
194
|
help="start debugpy listening (e.g. 127.0.0.1:5678)")
|
|
172
195
|
parser.add_argument("--wait-for-client", action="store_true",
|
|
@@ -201,8 +224,7 @@ def main(argv=None):
|
|
|
201
224
|
|
|
202
225
|
try:
|
|
203
226
|
py_path, map_path, result = build_file(
|
|
204
|
-
args.source, args.out,
|
|
205
|
-
rel=os.path.basename(args.source))
|
|
227
|
+
args.source, args.out, rel=shadow_rel(args.source, args.root))
|
|
206
228
|
except LdpySyntaxError as e:
|
|
207
229
|
print(str(e), file=sys.stderr)
|
|
208
230
|
return 1
|
ldpy/runtime.py
CHANGED
|
@@ -641,7 +641,6 @@ def add_to(graph, *triples, bindings=None):
|
|
|
641
641
|
s2, p2, o2 = term(s), term(p), term(o)
|
|
642
642
|
if s2 is not None and p2 is not None and o2 is not None:
|
|
643
643
|
graph.add((s2, p2, o2))
|
|
644
|
-
return graph
|
|
645
644
|
|
|
646
645
|
|
|
647
646
|
def remove_from(graph, *patterns, bindings=None):
|
|
@@ -665,13 +664,12 @@ def remove_from(graph, *patterns, bindings=None):
|
|
|
665
664
|
to_remove.add(inst)
|
|
666
665
|
for tr in to_remove:
|
|
667
666
|
graph.remove(tr)
|
|
668
|
-
return
|
|
667
|
+
return
|
|
669
668
|
term = _materializer(bindings, keep_vars=True)
|
|
670
669
|
for s, p, o in patterns:
|
|
671
670
|
tr = tuple(None if isinstance(x, (Variable, bn)) else x
|
|
672
671
|
for x in (term(s), term(p), term(o)))
|
|
673
672
|
graph.remove(tr)
|
|
674
|
-
return graph
|
|
675
673
|
|
|
676
674
|
|
|
677
675
|
def graph(namespaces, base, *triples, bindings=None):
|
ldpy/transpiler/core.py
CHANGED
|
@@ -345,13 +345,16 @@ class Transpiler:
|
|
|
345
345
|
self.operand = False
|
|
346
346
|
self.stmt_start = False
|
|
347
347
|
|
|
348
|
-
def _error(self, msg, line=None, col=None):
|
|
348
|
+
def _error(self, msg, line=None, col=None, incomplete=True):
|
|
349
349
|
exc = LdpySyntaxError(msg, self.filename,
|
|
350
350
|
self.src_line if line is None else line,
|
|
351
351
|
self.src_col if col is None else col)
|
|
352
352
|
# la console s'en sert pour distinguer « entrée incomplète » (îlot
|
|
353
|
-
# non fermé en fin de tampon) d'une vraie erreur de syntaxe
|
|
354
|
-
|
|
353
|
+
# non fermé en fin de tampon) d'une vraie erreur de syntaxe.
|
|
354
|
+
# `incomplete=False` : erreur qu'une suite d'entrée ne répare pas
|
|
355
|
+
# (elle porte sur ce qui a déjà été lu), même si le curseur est en
|
|
356
|
+
# fin de tampon — sinon la console attendrait indéfiniment.
|
|
357
|
+
exc.at_eof = incomplete and self.i >= self.n
|
|
355
358
|
raise exc
|
|
356
359
|
|
|
357
360
|
def _warn(self, msg):
|
|
@@ -675,7 +678,7 @@ class Transpiler:
|
|
|
675
678
|
if re.match(r"@(prefix|base|graph|bindings)\b", t[j:j + 10]):
|
|
676
679
|
self._close_copy()
|
|
677
680
|
self._take(m.end() - self.i) # le mot-clé
|
|
678
|
-
while self._peek() in " \t":
|
|
681
|
+
while self._peek() in (" ", "\t"):
|
|
679
682
|
self._take(1)
|
|
680
683
|
if not self._try_prefix_or_base(scope_mode=name):
|
|
681
684
|
self._error("déclaration d'îlot attendue après "
|
|
@@ -1388,7 +1391,8 @@ class Transpiler:
|
|
|
1388
1391
|
if not encl:
|
|
1389
1392
|
what = "prefix %s:" % name if kind == "prefix" else kind
|
|
1390
1393
|
self._error("nonlocal @%s : aucune déclaration englobante "
|
|
1391
|
-
"(comme le nonlocal de Python)" % what
|
|
1394
|
+
"(comme le nonlocal de Python)" % what,
|
|
1395
|
+
incomplete=False)
|
|
1392
1396
|
keep = encl[-1]
|
|
1393
1397
|
target_col = self._scope_stack[keep][0]
|
|
1394
1398
|
touched = [i for i in matches if i > keep]
|
|
@@ -1562,7 +1566,7 @@ class Transpiler:
|
|
|
1562
1566
|
return self._take(m.end() - self.i)
|
|
1563
1567
|
|
|
1564
1568
|
def _graph_ws_inline(self):
|
|
1565
|
-
while self._peek() in " \t":
|
|
1569
|
+
while self._peek() in (" ", "\t"):
|
|
1566
1570
|
self._take(1)
|
|
1567
1571
|
|
|
1568
1572
|
def _addremove_island(self, sign):
|
|
@@ -1581,7 +1585,7 @@ class Transpiler:
|
|
|
1581
1585
|
self._error("'%s{ ... }' sans graphe courant : déclarez-le avec "
|
|
1582
1586
|
"'@graph <expression>' ou '@graph as g' (fiche 014), "
|
|
1583
1587
|
"ou donnez-le en suffixe — %s{ ... }(g)"
|
|
1584
|
-
% (sign, sign))
|
|
1588
|
+
% (sign, sign), incomplete=False)
|
|
1585
1589
|
bvar = sfx_bindings if sfx_bindings else self._bindings_var
|
|
1586
1590
|
fn = "add_to" if sign == "+" else "remove_from"
|
|
1587
1591
|
args = [gvar]
|
|
@@ -2482,7 +2486,7 @@ class Transpiler:
|
|
|
2482
2486
|
if word.upper() == "BOUND" and after == "(":
|
|
2483
2487
|
self._take(len(word) + 1)
|
|
2484
2488
|
self._e_ws()
|
|
2485
|
-
if self._peek() not in "
|
|
2489
|
+
if self._peek() not in ("?", "$"):
|
|
2486
2490
|
self._error("BOUND attend une variable ?v")
|
|
2487
2491
|
self._take(1)
|
|
2488
2492
|
vm = _NAME_RE.match(t, self.i)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: linked-data-python
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.2
|
|
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
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
ldpy/__init__.py,sha256=IyuzHrp5OtuGO_NrrdmMUQW6bTYcyS5uob7CeoXg8mY,1943
|
|
2
2
|
ldpy/__main__.py,sha256=YKTEjmNQuh_0p-KiEus9HngFs_ZDmS56RXzHTspiWVI,3077
|
|
3
3
|
ldpy/build.py,sha256=495F9KyFMar-hTCuaQkF3FvzWQX4mE9H0U0V-JuRDmA,3394
|
|
4
|
-
ldpy/console.py,sha256=
|
|
5
|
-
ldpy/debug.py,sha256=
|
|
4
|
+
ldpy/console.py,sha256=vMSnFFoOIOcanw6_niNxqgrt-F4gzMOrD1GopkXru5s,4837
|
|
5
|
+
ldpy/debug.py,sha256=JUuzeKc8ya4SG30AxaUVeihTEbzySo1cS0sU0s78Mv0,10493
|
|
6
6
|
ldpy/formatter.py,sha256=VaDPECxhivsMe8jnX_fOL7BUyLEu5r4xREdr4Hav-0c,12695
|
|
7
7
|
ldpy/importer.py,sha256=QXAhSujPN6rFMJSQuj0UsWyI4CajirKt1SOrykJ_fUw,3670
|
|
8
8
|
ldpy/pygments_lexer.py,sha256=mcQ0u9nZjLnSWpqzcxd6bZjk69LfKSNTsf9A3rqfhhk,25320
|
|
9
|
-
ldpy/runtime.py,sha256=
|
|
9
|
+
ldpy/runtime.py,sha256=InXxP1kwxrtozYZAqW6J-fmmUYiI_ykFswvZ_mK5TTY,36000
|
|
10
10
|
ldpy/sparql.py,sha256=CHSB4v5lEuVQKRPuwcM8xI3jN2FVHkmPVb675QkAD9Y,14770
|
|
11
11
|
ldpy/lsp/__init__.py,sha256=rK5GYOITi9PN09-WVlJ2aPKodW8dWTpgI_X6dFbP1zA,542
|
|
12
12
|
ldpy/lsp/__main__.py,sha256=MIp4ktqaoWZCNIMfv14bSC9pqK86JBS5XVjd1Z3c24o,72
|
|
@@ -17,12 +17,12 @@ ldpy/lsp/rpc.py,sha256=-TF_9U8dum23Pi4O1FZLogwoZgrGrt14J5BFB1OYVZw,3554
|
|
|
17
17
|
ldpy/lsp/server.py,sha256=PAMMookGUn00vAW_-a5BGy3qkVe9PoUdfzAzpdlvoF8,16359
|
|
18
18
|
ldpy/lsp/translate.py,sha256=HU9fBP_xWyYLih6QwQfSoyfF-MH-oInFcPX3o8Vc2GI,6116
|
|
19
19
|
ldpy/transpiler/__init__.py,sha256=9mQx0e47ixz0iMqSbCBbtGiwJ7PLxTcsVSIp6KNTMG4,504
|
|
20
|
-
ldpy/transpiler/core.py,sha256=
|
|
20
|
+
ldpy/transpiler/core.py,sha256=XiRuq9YbFnvNiWo4kio0Rd5a6KsC4Om-1NIMIAbaK5M,113824
|
|
21
21
|
ldpy/transpiler/errors.py,sha256=zEEwsNvC2Tawq8jIYls7hrbcWSvQtd7eo89k_SKp0k0,1142
|
|
22
22
|
ldpy/transpiler/linemap.py,sha256=ecLlCUkD4-6QQtUjGfAL28ql7LPITTS4fjLcDIbAwpQ,11386
|
|
23
|
-
linked_data_python-0.5.
|
|
24
|
-
linked_data_python-0.5.
|
|
25
|
-
linked_data_python-0.5.
|
|
26
|
-
linked_data_python-0.5.
|
|
27
|
-
linked_data_python-0.5.
|
|
28
|
-
linked_data_python-0.5.
|
|
23
|
+
linked_data_python-0.5.2.dist-info/licenses/LICENSE.md,sha256=R6KjQ098eAFd2k5mKaSRJqMH1LhY4o7xkHrKT5vjRfs,1074
|
|
24
|
+
linked_data_python-0.5.2.dist-info/METADATA,sha256=6zP3Q2bhARECaLwSWW77SOhSE9mbmtqXzefvYM_zu_c,7974
|
|
25
|
+
linked_data_python-0.5.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
26
|
+
linked_data_python-0.5.2.dist-info/entry_points.txt,sha256=n8Vs52oH81BrKOe1DNUvdFLSOlEufRMpK2waPFa6aYk,224
|
|
27
|
+
linked_data_python-0.5.2.dist-info/top_level.txt,sha256=dkG_F4jYkh6CS6gdpQeV_gKW3yaJBvl1ukUu0zo2KA8,5
|
|
28
|
+
linked_data_python-0.5.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{linked_data_python-0.5.1.dist-info → linked_data_python-0.5.2.dist-info}/licenses/LICENSE.md
RENAMED
|
File without changes
|
|
File without changes
|