dyngle 0.4.0__py3-none-any.whl → 0.4.1__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.
Potentially problematic release.
This version of dyngle might be problematic. Click here for more details.
dyngle/template.py
CHANGED
|
@@ -11,15 +11,17 @@ class Template:
|
|
|
11
11
|
|
|
12
12
|
template: str
|
|
13
13
|
|
|
14
|
-
def render(self, data: dict, expressions: dict = None) -> str:
|
|
14
|
+
def render(self, data: dict = None, expressions: dict = None) -> str:
|
|
15
15
|
"""Render the template with the provided data."""
|
|
16
|
+
data = data if data else {}
|
|
17
|
+
expressions = expressions if expressions else {}
|
|
16
18
|
resolver = partial(self._resolve, data=data, expressions=expressions)
|
|
17
19
|
return PATTERN.sub(resolver, self.template)
|
|
18
20
|
|
|
19
21
|
def _resolve(self, match, *, data: dict, expressions: dict):
|
|
20
22
|
"""Resolve a single name/path from the template."""
|
|
21
23
|
key = match.group(1).strip()
|
|
22
|
-
if
|
|
24
|
+
if key in expressions:
|
|
23
25
|
return expressions[key](data)
|
|
24
26
|
else:
|
|
25
27
|
parts = key.split('.')
|
|
@@ -5,8 +5,8 @@ dyngle/command/run_command.py,sha256=0E8Bg7TRa8qXdfZNyC4Wygb1cEG4-ejRJ5ZfYz_L1_Y
|
|
|
5
5
|
dyngle/error.py,sha256=CGcTa8L4O1qsHEYnzp_JBbkvntJTv2Qz46wj_TI8NLk,39
|
|
6
6
|
dyngle/expression.py,sha256=x-2Ald34lmXfG8070H96Wszln5Rd1AWGyYuYtf7iZFA,2134
|
|
7
7
|
dyngle/safe_path.py,sha256=Hk2AhP6e3yKGh3kKrLLwhvAlMNx-j2jObBYJL-_doAU,3339
|
|
8
|
-
dyngle/template.py,sha256=
|
|
9
|
-
dyngle-0.4.
|
|
10
|
-
dyngle-0.4.
|
|
11
|
-
dyngle-0.4.
|
|
12
|
-
dyngle-0.4.
|
|
8
|
+
dyngle/template.py,sha256=jE-rJiR2kZBHrjy_VJyiXCr4uu1JH8JCafShrMK9lVM,937
|
|
9
|
+
dyngle-0.4.1.dist-info/METADATA,sha256=YrLmiJGFF2HI_eyNCeJVzKoRw352RJea_Vr4J3xGiQc,2941
|
|
10
|
+
dyngle-0.4.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
11
|
+
dyngle-0.4.1.dist-info/entry_points.txt,sha256=rekiGhtweiHKm9g1jdGb3FhzqDrk1kigJDeSNollZSA,48
|
|
12
|
+
dyngle-0.4.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|