robotcode-core 2.9.0.dev230__py3-none-any.whl → 2.9.0.dev264__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.
- robotcode/core/__version__.py +1 -1
- robotcode/core/uri.py +89 -2
- {robotcode_core-2.9.0.dev230.dist-info → robotcode_core-2.9.0.dev264.dist-info}/METADATA +1 -1
- {robotcode_core-2.9.0.dev230.dist-info → robotcode_core-2.9.0.dev264.dist-info}/RECORD +5 -5
- {robotcode_core-2.9.0.dev230.dist-info → robotcode_core-2.9.0.dev264.dist-info}/WHEEL +0 -0
robotcode/core/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.9.0-dev.
|
|
1
|
+
__version__ = "2.9.0-dev.264"
|
robotcode/core/uri.py
CHANGED
|
@@ -5,7 +5,7 @@ import re
|
|
|
5
5
|
import sys
|
|
6
6
|
from dataclasses import astuple, dataclass, fields
|
|
7
7
|
from pathlib import Path
|
|
8
|
-
from typing import Any, Iterator, Mapping, Optional, Union, overload
|
|
8
|
+
from typing import Any, Iterable, Iterator, Mapping, Optional, Union, overload
|
|
9
9
|
from urllib import parse
|
|
10
10
|
|
|
11
11
|
from .utils.path import normalized_path
|
|
@@ -21,6 +21,80 @@ class InvalidUriError(Exception):
|
|
|
21
21
|
pass
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
@dataclass(frozen=True)
|
|
25
|
+
class PathMapping:
|
|
26
|
+
"""A root of the client's file URIs, such as `file://wsl.localhost/Ubuntu/`, and the local path it stands for,
|
|
27
|
+
such as `/`."""
|
|
28
|
+
|
|
29
|
+
client_root: str
|
|
30
|
+
local_root: str
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(frozen=True)
|
|
34
|
+
class _ParsedPathMapping:
|
|
35
|
+
client_root: str
|
|
36
|
+
scheme: str
|
|
37
|
+
netloc: str
|
|
38
|
+
segments: tuple[str, ...]
|
|
39
|
+
local_root: str
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
_path_mappings: list[_ParsedPathMapping] = []
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _segments(path: str) -> list[str]:
|
|
46
|
+
return [s for s in path.split("/") if s]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def set_path_mappings(mappings: Iterable[PathMapping]) -> None:
|
|
50
|
+
"""Sets the path mappings of this process. A client URI below a client root becomes a path below its local root,
|
|
51
|
+
and a path below a local root becomes a URI below its client root; the longest root wins."""
|
|
52
|
+
parsed = []
|
|
53
|
+
for m in mappings:
|
|
54
|
+
client_root = m.client_root if m.client_root.endswith("/") else m.client_root + "/"
|
|
55
|
+
parts = parse.urlparse(client_root)
|
|
56
|
+
local_root = m.local_root.replace("\\", "/")
|
|
57
|
+
if not local_root.endswith("/"):
|
|
58
|
+
local_root += "/"
|
|
59
|
+
parsed.append(
|
|
60
|
+
_ParsedPathMapping(
|
|
61
|
+
client_root,
|
|
62
|
+
parts.scheme.lower(),
|
|
63
|
+
parse.unquote(parts.netloc).lower(),
|
|
64
|
+
tuple(s.lower() for s in _segments(parse.unquote(parts.path))),
|
|
65
|
+
local_root,
|
|
66
|
+
)
|
|
67
|
+
)
|
|
68
|
+
_path_mappings[:] = parsed
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _client_to_local(scheme: str, netloc: str, path: str) -> Optional[str]:
|
|
72
|
+
segments = _segments(path)
|
|
73
|
+
lowered = [s.lower() for s in segments]
|
|
74
|
+
best: Optional[_ParsedPathMapping] = None
|
|
75
|
+
for m in _path_mappings:
|
|
76
|
+
if (
|
|
77
|
+
m.scheme == scheme.lower()
|
|
78
|
+
and m.netloc == netloc.lower()
|
|
79
|
+
and tuple(lowered[: len(m.segments)]) == m.segments
|
|
80
|
+
and (best is None or len(m.segments) > len(best.segments))
|
|
81
|
+
):
|
|
82
|
+
best = m
|
|
83
|
+
if best is None:
|
|
84
|
+
return None
|
|
85
|
+
return best.local_root + "/".join(segments[len(best.segments) :])
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _local_to_client(path: str) -> Optional[str]:
|
|
89
|
+
best: Optional[_ParsedPathMapping] = None
|
|
90
|
+
for m in _path_mappings:
|
|
91
|
+
if (path + "/").startswith(m.local_root) and (best is None or len(m.local_root) > len(best.local_root)):
|
|
92
|
+
best = m
|
|
93
|
+
if best is None:
|
|
94
|
+
return None
|
|
95
|
+
return best.client_root + parse.quote(path[len(best.local_root) :])
|
|
96
|
+
|
|
97
|
+
|
|
24
98
|
@dataclass
|
|
25
99
|
class _Parts:
|
|
26
100
|
scheme: str = _DEFAULT_SCHEME
|
|
@@ -124,7 +198,15 @@ class Uri(Mapping[str, str]):
|
|
|
124
198
|
if self._parts.scheme not in ["file", "untitled"]:
|
|
125
199
|
raise InvalidUriError(f"Invalid URI scheme '{self!s}'.")
|
|
126
200
|
|
|
127
|
-
|
|
201
|
+
mapped = (
|
|
202
|
+
_client_to_local(self._parts.scheme, netloc, path)
|
|
203
|
+
if _path_mappings and self._parts.scheme == "file"
|
|
204
|
+
else None
|
|
205
|
+
)
|
|
206
|
+
if mapped is not None:
|
|
207
|
+
value = mapped
|
|
208
|
+
|
|
209
|
+
elif netloc and self._parts.scheme == "file":
|
|
128
210
|
# unc path: file://shares/c$/far/boo
|
|
129
211
|
value = "//{}{}".format(netloc, path or "")
|
|
130
212
|
|
|
@@ -167,6 +249,11 @@ class Uri(Mapping[str, str]):
|
|
|
167
249
|
|
|
168
250
|
@staticmethod
|
|
169
251
|
def from_path(path: Union[str, Path, os.PathLike[str]]) -> Uri:
|
|
252
|
+
if _path_mappings:
|
|
253
|
+
mapped = _local_to_client(Path(path).as_posix())
|
|
254
|
+
if mapped is not None:
|
|
255
|
+
return Uri(mapped)
|
|
256
|
+
|
|
170
257
|
result = Uri(Path(path).as_uri())
|
|
171
258
|
|
|
172
259
|
result._parts.path = parse.quote(parse.unquote(result._parts.path))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
robotcode/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
robotcode/core/__version__.py,sha256=
|
|
2
|
+
robotcode/core/__version__.py,sha256=VN16WdRl9zxi7GbqkKoJDxt27F6zUDxjqn8r4zFJsGs,30
|
|
3
3
|
robotcode/core/async_tools.py,sha256=pU12trR8-w4oUoLXiV5uGQ9weGZS25b_DXCNwbbhcfI,12843
|
|
4
4
|
robotcode/core/concurrent.py,sha256=-WPaxSsS7Vgzc3PyANtfBLHznZTPZ36T0ftRHzKO584,7058
|
|
5
5
|
robotcode/core/documents_manager.py,sha256=H3zNfQaXTYaXt5LDdkQDNeRNhDXc0SD9RLMRv1TN2jc,7937
|
|
@@ -10,7 +10,7 @@ robotcode/core/language.py,sha256=Kg5zuQEE4atSD2lXk2Q2OwEBW5rJodo_MzikdfDTZKQ,11
|
|
|
10
10
|
robotcode/core/py.typed,sha256=bWew9mHgMy8LqMu7RuqQXFXLBxh2CRx0dUbSx-3wE48,27
|
|
11
11
|
robotcode/core/text_document.py,sha256=NqQQ4YHHHWkgqMBnLxxC5fQvxLeQ9hhEJkaEm7Wai_c,13712
|
|
12
12
|
robotcode/core/types.py,sha256=xxDJsW3h_ygJTRtehalYAU9LsMHdbbBHCQapWA27i38,443
|
|
13
|
-
robotcode/core/uri.py,sha256=
|
|
13
|
+
robotcode/core/uri.py,sha256=QKWmByg8I_dLl82OROkAUoIdGd30Ifxau0CNus49Vqo,8763
|
|
14
14
|
robotcode/core/workspace.py,sha256=QV2qffKfgvZg_pqiTSrmqLA22I6evEfJpAVi8YeAvC8,2631
|
|
15
15
|
robotcode/core/lsp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
robotcode/core/lsp/types.py,sha256=EhlnFsD_ncbS_9V4tiFKQfFh1DYA_k9S6qT1B8PKHKE,238481
|
|
@@ -27,6 +27,6 @@ robotcode/core/utils/path.py,sha256=RDhRcLFXami154-zCe6GeYFyuL2Fuwrd8Teh-bPlIbA,
|
|
|
27
27
|
robotcode/core/utils/process.py,sha256=nwTTmAyjcDybcO_fq0ZbZK_76ndBFO324z9cxni8TuU,679
|
|
28
28
|
robotcode/core/utils/safe_eval.py,sha256=ES12mwdqNH4iHsP23sEBW6_bgGjS5DKFfgSfxP97-ok,1448
|
|
29
29
|
robotcode/core/utils/version.py,sha256=uXcvqOFLbaSH5EWL6OwRDZjGteFzwaqt0Ll2Rf5h008,1373
|
|
30
|
-
robotcode_core-2.9.0.
|
|
31
|
-
robotcode_core-2.9.0.
|
|
32
|
-
robotcode_core-2.9.0.
|
|
30
|
+
robotcode_core-2.9.0.dev264.dist-info/METADATA,sha256=EgMaNRecitggZRUemw6iMvGsk_ho2dqU9oWo4Iqs92I,2764
|
|
31
|
+
robotcode_core-2.9.0.dev264.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
32
|
+
robotcode_core-2.9.0.dev264.dist-info/RECORD,,
|
|
File without changes
|