moat-lib-path 0.3.2__tar.gz → 0.3.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moat-lib-path
3
- Version: 0.3.2
3
+ Version: 0.3.5
4
4
  Summary: Hierarchical path representation and manipulation for MoaT
5
5
  Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
6
6
  Project-URL: homepage, https://m-o-a-t.org
@@ -16,7 +16,7 @@ Requires-Python: >=3.8
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE.txt
18
18
  Requires-Dist: anyio~=4.0
19
- Requires-Dist: moat-lib-proxy~=0.1.1
19
+ Requires-Dist: moat-lib-proxy~=0.1.3
20
20
  Requires-Dist: regex
21
21
  Dynamic: license-file
22
22
 
@@ -1,3 +1,39 @@
1
+ moat-lib-path (0.3.5-1) unstable; urgency=medium
2
+
3
+ * New release for 26.4.0
4
+
5
+ -- Matthias Urlichs <matthias@urlichs.de> Tue, 29 Sep 2026 16:47:45 +0200
6
+
7
+ moat-lib-path (0.3.4-1) unstable; urgency=medium
8
+
9
+ * New release for 26.2.13
10
+
11
+ -- Matthias Urlichs <matthias@urlichs.de> Wed, 23 Sep 2026 15:11:26 +0200
12
+
13
+ moat-lib-path (0.3.3-3) unstable; urgency=medium
14
+
15
+ * New release for 26.2.3
16
+
17
+ -- Matthias Urlichs <matthias@urlichs.de> Mon, 15 Jun 2026 18:03:16 +0200
18
+
19
+ moat-lib-path (0.3.3-2) unstable; urgency=medium
20
+
21
+ * New release for 26.1.12
22
+
23
+ -- Matthias Urlichs <matthias@urlichs.de> Fri, 24 Apr 2026 15:40:58 +0200
24
+
25
+ moat-lib-path (0.3.3-1) unstable; urgency=medium
26
+
27
+ * New release for 26.1.10
28
+
29
+ -- Matthias Urlichs <matthias@urlichs.de> Thu, 23 Apr 2026 21:17:55 +0200
30
+
31
+ moat-lib-path (0.3.2-2) unstable; urgency=medium
32
+
33
+ * New release for 26.1.7
34
+
35
+ -- Matthias Urlichs <matthias@urlichs.de> Wed, 15 Apr 2026 16:36:43 +0200
36
+
1
37
  moat-lib-path (0.3.2-1) unstable; urgency=medium
2
38
 
3
39
  * New release for 26.1.5
@@ -2,12 +2,11 @@ Source: moat-lib-path
2
2
  Maintainer: "Matthias Urlichs" <matthias@urlichs.de>
3
3
  Section: python
4
4
  Priority: optional
5
- Build-Depends: dh-python, python3-all, debhelper (>= 13),
5
+ Build-Depends: dh-python, python3-all, debhelper (>= 13), debhelper-compat (= 13),
6
6
  python3-setuptools,
7
7
  python3-wheel,
8
8
  Standards-Version: 3.9.6
9
9
  Homepage: https://m-o-a-t.org
10
- X-DH-Compat: 13
11
10
 
12
11
  Package: python3-moat-lib-path
13
12
  Architecture: all
@@ -13,7 +13,7 @@ classifiers = [
13
13
  ]
14
14
  dependencies = [
15
15
  "anyio ~= 4.0",
16
- "moat-lib-proxy ~= 0.1.1",
16
+ "moat-lib-proxy ~= 0.1.3",
17
17
  "regex",
18
18
  ]
19
19
  keywords = ["MoaT"]
@@ -22,7 +22,7 @@ name = "moat-lib-path"
22
22
  maintainers = [{email = "matthias@urlichs.de",name = "Matthias Urlichs"}]
23
23
  description='Hierarchical path representation and manipulation for MoaT'
24
24
  readme = "README.md"
25
- version = "0.3.2"
25
+ version = "0.3.5"
26
26
 
27
27
  [project.urls]
28
28
  homepage = "https://m-o-a-t.org"
@@ -130,6 +130,7 @@ class Path(Sequence[PathElem]):
130
130
  :Q An alias for an alternate root
131
131
  :P An alias for another alternate root
132
132
  :S An alias for yet another alternate root
133
+ :T An alias for a root used for testing
133
134
  :@ Marks this path as relative
134
135
 
135
136
  The empty path is denoted by a single colon. A path that starts or ends
@@ -343,7 +344,7 @@ class Path(Sequence[PathElem]):
343
344
  Slash encoding does not work with empty paths; marks are ignored.
344
345
 
345
346
  Roots are expanded when slashed. Otherwise they are represented
346
- as ``:S``, ``:P``, ``:Q``, or ``:R``.
347
+ as ``:S``, ``:P``, ``:Q``, ``:R``, or ":T".
347
348
  """
348
349
 
349
350
  def _escol(x, spaces=True):
@@ -611,6 +612,9 @@ class Path(Sequence[PathElem]):
611
612
  def __repr__(self):
612
613
  return f"P({str(self)!r})"
613
614
 
615
+ def __format__(self, spec):
616
+ return str(self).__format__(spec)
617
+
614
618
  @classmethod
615
619
  def from_str(cls, path, *, mark="", scan=False):
616
620
  """
@@ -1107,7 +1111,7 @@ class PathLongener:
1107
1111
  Caution: this longener ignores path marks.
1108
1112
  """
1109
1113
 
1110
- cls = Path
1114
+ cls: type[Path] = Path
1111
1115
 
1112
1116
  def __init__(self, prefix: Path | PathTuple = ()):
1113
1117
  if isinstance(prefix, Path):
@@ -1154,6 +1158,24 @@ path_eval = _eval.eval
1154
1158
  # Here we declare our bunch of "root" variables.
1155
1159
 
1156
1160
 
1161
+ class _NoResetToken:
1162
+ """Token returned by :meth:`Var.set`.
1163
+
1164
+ ``Var`` has no context to restore, so unlike a real ``ContextVar`` token
1165
+ this carries no state: its only job is to be recognisable to
1166
+ :meth:`Var.reset` so the ``set``/``reset`` protocol driven by ``ctx_as``
1167
+ works uniformly for both ``ContextVar`` and ``Var``.
1168
+ """
1169
+
1170
+ __slots__ = ()
1171
+
1172
+ def __repr__(self) -> str:
1173
+ return "<Var no-reset token>"
1174
+
1175
+
1176
+ _VAR_SET_TOKEN = _NoResetToken()
1177
+
1178
+
1157
1179
  class Var:
1158
1180
  """
1159
1181
  This mimics a ContextVar but without the context.
@@ -1175,12 +1197,29 @@ class Var:
1175
1197
  # If the root is a.b.c, a new identical value will arrive as an
1176
1198
  # empty path with a root of a.b.c. That's bad. Thus silently don't
1177
1199
  # update in that case.
1200
+ #
1201
+ # We detect that case structurally.
1202
+ #
1203
+ # Match by the RootPath's *key* ("R"), not by ``_var is self``:
1204
+ # the ``RootPath`` embedded in @val may hold a stale ``Var`` (a
1205
+ # second ``Root`` instance created, if the namespace-packaged
1206
+ # ``moat.lib.path._impl`` is loaded more than once), so identity
1207
+ # would fail even though @val denotes the same root.
1208
+ if (
1209
+ not force
1210
+ and self.data is not NotGiven
1211
+ and isinstance(val, Path)
1212
+ and isinstance(val._prefix, RootPath) # noqa:SLF001
1213
+ and val._prefix._key == "R" # noqa:SLF001
1214
+ and not len(val._data) # noqa:SLF001
1215
+ ):
1216
+ return _VAR_SET_TOKEN
1178
1217
  if not force and self.data is not NotGiven:
1179
1218
  if self.data.slashed != val.slashed:
1180
1219
  raise ValueError("Already set", self.data, val)
1181
- return 42
1220
+ return _VAR_SET_TOKEN
1182
1221
  self.data = val
1183
- return 42
1222
+ return _VAR_SET_TOKEN
1184
1223
 
1185
1224
  def __bool__(self):
1186
1225
  "check if value is set"
@@ -1188,7 +1227,7 @@ class Var:
1188
1227
 
1189
1228
  def reset(self, token):
1190
1229
  "reset value; no-op"
1191
- if token != 42:
1230
+ if token is not _VAR_SET_TOKEN:
1192
1231
  raise ValueError(token)
1193
1232
 
1194
1233
 
@@ -1242,7 +1281,7 @@ _root = RootPath("R", Root)
1242
1281
  as_proxy("R", _root)
1243
1282
  _Roots = {"R": _root}
1244
1283
 
1245
- for _idx in "SPQ": # and R. Yes I know.
1284
+ for _idx in "SPQT": # and R. Yes I know.
1246
1285
  _name = f"{_idx}_Root"
1247
1286
  _ctx = ContextVar[Path | None](_name, default=None)
1248
1287
  _path = RootPath(_idx, _ctx)
@@ -1259,5 +1298,6 @@ if TYPE_CHECKING:
1259
1298
  S_Root = ContextVar[Path | None]("S_Root", default=None)
1260
1299
  P_Root = ContextVar[Path | None]("P_Root", default=None)
1261
1300
  Q_Root = ContextVar[Path | None]("Q_Root", default=None)
1301
+ T_Root = ContextVar[Path | None]("T_Root", default=None)
1262
1302
 
1263
- __all__ += ["P_Root", "Q_Root", "S_Root"]
1303
+ __all__ += ["P_Root", "Q_Root", "S_Root", "T_Root"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moat-lib-path
3
- Version: 0.3.2
3
+ Version: 0.3.5
4
4
  Summary: Hierarchical path representation and manipulation for MoaT
5
5
  Maintainer-email: Matthias Urlichs <matthias@urlichs.de>
6
6
  Project-URL: homepage, https://m-o-a-t.org
@@ -16,7 +16,7 @@ Requires-Python: >=3.8
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE.txt
18
18
  Requires-Dist: anyio~=4.0
19
- Requires-Dist: moat-lib-proxy~=0.1.1
19
+ Requires-Dist: moat-lib-proxy~=0.1.3
20
20
  Requires-Dist: regex
21
21
  Dynamic: license-file
22
22
 
@@ -0,0 +1,3 @@
1
+ anyio~=4.0
2
+ moat-lib-proxy~=0.1.3
3
+ regex
@@ -1,3 +0,0 @@
1
- anyio~=4.0
2
- moat-lib-proxy~=0.1.1
3
- regex
File without changes
File without changes
File without changes
File without changes