combycode-dpe 2.0.4__py3-none-any.whl → 2.1.0__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: combycode-dpe
3
- Version: 2.0.4
3
+ Version: 2.1.0
4
4
  Summary: DPE framework for building streaming pipeline tools in Python
5
5
  Project-URL: Homepage, https://github.com/combycode/dpe
6
6
  Project-URL: Repository, https://github.com/combycode/dpe
@@ -3,8 +3,8 @@ dpe/_accumulators.py,sha256=7m2rP4qQ_Kh9AGU-iwC53jcS08GVQE4wqGMGa5Yj6pc,7072
3
3
  dpe/_cache.py,sha256=Nd6UfNhRxA3ZivYewrRQ_-CTG1NI_Y2F3KBCX7Inyk8,2809
4
4
  dpe/_context.py,sha256=Nqe5hJCk1T1WFPFwAhCAvIxVKDt9E_vHceHh8KcwdqI,5638
5
5
  dpe/_envelope.py,sha256=H9oqSUqUcR-ipKbyTO81cEg0KNLzi8ND-aKwDn8N7So,4455
6
- dpe/_paths.py,sha256=AiGtR_ULKHLgBL9ali4c9wIfo7e1FcKnwiTRNmxqMPU,3728
6
+ dpe/_paths.py,sha256=cb1LBN08x6eENM_j9eKX2pPbFhHH_C7cPY1Ns0zJJcs,4634
7
7
  dpe/_runtime.py,sha256=RcrJzp4U9koL7ey2YiO7-xCk0bm2QQU2omGur3PfnXQ,5539
8
- combycode_dpe-2.0.4.dist-info/METADATA,sha256=0-DjgKGZuT-x99j89CfF4QSjkdsWYBri8NFAk5Vugis,4069
9
- combycode_dpe-2.0.4.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
10
- combycode_dpe-2.0.4.dist-info/RECORD,,
8
+ combycode_dpe-2.1.0.dist-info/METADATA,sha256=H03rDWsxdeOlOBeAiraHxzcNM_Q1ZkZxTPEz6InC6vc,4069
9
+ combycode_dpe-2.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
10
+ combycode_dpe-2.1.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.30.1
2
+ Generator: hatchling 1.33.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
dpe/_paths.py CHANGED
@@ -5,6 +5,8 @@ Input side (runtime, before processor): $token/subpath -> absolute path
5
5
  Output side (context.output / context.meta): absolute path -> $token/subpath
6
6
 
7
7
  Both sides are a no-op when the DPE_* env vars are not set.
8
+ ``DPE_PATH_TOKENS=off`` (also ``0`` / ``false`` / ``no``) turns the output side off; the
9
+ runner sets it from the variant's / stage's ``path_tokens``. Input resolution stays on.
8
10
  """
9
11
 
10
12
  import os
@@ -20,10 +22,18 @@ _TOKEN_MAP = [
20
22
  ]
21
23
 
22
24
 
25
+ def tokens_enabled_from_env() -> bool:
26
+ """True unless ``DPE_PATH_TOKENS`` is ``off``, ``0``, ``false`` or ``no`` (any case)."""
27
+ v = os.environ.get("DPE_PATH_TOKENS")
28
+ if v is None:
29
+ return True
30
+ return v.strip().lower() not in ("off", "0", "false", "no")
31
+
32
+
23
33
  class EnvPaths:
24
34
  """Resolved env prefix map. Build once at tool startup."""
25
35
 
26
- __slots__ = ("_entries",)
36
+ __slots__ = ("_entries", "_no_tokenize")
27
37
 
28
38
  def __init__(self, pairs: list[tuple[str, str]] | None = None):
29
39
  """
@@ -47,6 +57,16 @@ class EnvPaths:
47
57
  self._entries: list[tuple[str, str]] = sorted(
48
58
  raw, key=lambda e: len(e[1]), reverse=True
49
59
  )
60
+ self._no_tokenize = (not tokens_enabled_from_env()) if pairs is None else False
61
+
62
+ def with_tokenize(self, on: bool) -> "EnvPaths":
63
+ """Turn the output side (absolute path -> ``$token``) on or off."""
64
+ self._no_tokenize = not on
65
+ return self
66
+
67
+ def tokenize_enabled(self) -> bool:
68
+ """Whether :meth:`tokenize_value` rewrites anything."""
69
+ return not self._no_tokenize
50
70
 
51
71
  @classmethod
52
72
  def from_env(cls) -> "EnvPaths":
@@ -69,7 +89,7 @@ class EnvPaths:
69
89
 
70
90
  def tokenize_value(self, v: Any) -> Any:
71
91
  """Walk v, tokenizing absolute paths back to $token[/subpath] form."""
72
- if self.is_empty():
92
+ if self.is_empty() or self._no_tokenize:
73
93
  return v
74
94
  return self._walk(v, self._tokenize_str)
75
95