dirigent-common 0.16.2__tar.gz → 0.16.3__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.
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/PKG-INFO +1 -1
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/pyproject.toml +1 -1
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/pyproject.toml.orig +1 -1
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/templating.py +9 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/LICENSE +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/README.md +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/__init__.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/clients.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/docstrings.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/durations.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/formats.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/formatters.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/names.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/programs.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/py.typed +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/schemas.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/sizes.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/types.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/uris.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/values.py +0 -0
- {dirigent_common-0.16.2 → dirigent_common-0.16.3}/src/dirigent_common/versions.py +0 -0
|
@@ -126,6 +126,11 @@ def render(source: str | jinja2.Template, context: Mapping[str, Any], *, max_byt
|
|
|
126
126
|
|
|
127
127
|
The cap is enforced as the text is generated, so a runaway loop stops at the cap rather
|
|
128
128
|
than after it has built the whole string.
|
|
129
|
+
|
|
130
|
+
Anything a template does while it renders -- dividing by zero, a filter refusing what it
|
|
131
|
+
was handed, a macro that recurses, an object in the context that raises when it is read --
|
|
132
|
+
leaves as a ``TemplateError``, so text that could not be produced never takes down the
|
|
133
|
+
work that asked for it.
|
|
129
134
|
"""
|
|
130
135
|
template = compile_template(source) if isinstance(source, str) else source
|
|
131
136
|
chunks: list[str] = []
|
|
@@ -136,6 +141,8 @@ def render(source: str | jinja2.Template, context: Mapping[str, Any], *, max_byt
|
|
|
136
141
|
size += len(chunk.encode())
|
|
137
142
|
if size > max_bytes:
|
|
138
143
|
raise RenderTooLarge(max_bytes)
|
|
144
|
+
except RenderTooLarge:
|
|
145
|
+
raise
|
|
139
146
|
except (jinja2.TemplateNotFound, jinja2.TemplatesNotFound) as error:
|
|
140
147
|
raise TemplateError(f"no template named {error.message}: a template cannot pull in another") from error
|
|
141
148
|
except (jinja2.UndefinedError, jinja2.exceptions.SecurityError) as error:
|
|
@@ -145,4 +152,6 @@ def render(source: str | jinja2.Template, context: Mapping[str, Any], *, max_byt
|
|
|
145
152
|
if "no loader" in str(error):
|
|
146
153
|
raise TemplateError("a template cannot include, import or extend another") from error
|
|
147
154
|
raise TemplateError(str(error)) from error
|
|
155
|
+
except Exception as error:
|
|
156
|
+
raise TemplateError(f"{type(error).__name__}: {error}") from error
|
|
148
157
|
return "".join(chunks)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|