Skip to main content

Data Stewardship Wizard: Templating

GitHub release (latest SemVer) PyPI LICENSE CII Best Practices Python Version

Rendering of Data Stewardship Wizard document templates

The engine behind the document worker: it renders a document from a document template on disk and a document context, with no database, storage or queue behind it.

Installation

pip install dsw-templating
pip install 'dsw-templating[all]'  # every optional step dependency
Extra Needed for
pdf weasyprint step (WeasyPrint, needs Pango installed)
rdf rdflib-convert step and the rdflib global in Jinja templates
excel excel step (XlsxWriter)
docx the pandoc-docx-pagebreakpy Pandoc filter command (panflute)
http requests global in Jinja templates (Requests)

A step whose extra is missing raises MissingExtraError ("install dsw-templating[pdf]") when it is used. The pandoc step needs the pandoc executable.

Usage

import json
import pathlib

from dsw.templating import RenderContext, RenderSettings, Template

template = Template.from_directory(pathlib.Path('my-template'), settings=RenderSettings())
context = json.loads(pathlib.Path('context.json').read_text())
document = template.render('d3e98eb6-344d-481f-8e37-6a67b6cd1ad2', context,
                           render_ctx=RenderContext.null(language='en'))
document.store('document')  # document.<extension>

Everything the rendering depends on is passed in explicitly:

Input Purpose
Template(template_dir=..., formats=..., assets=...) Template files on disk and the formats of template.json (from_directory reads both)
RenderSettings URL security policy (SecuritySettings), Pandoc command, filters and timeout (PandocSettings), per-template secrets and HTTP requests (TemplateSettings)
RenderContext Translations (gettext), language and locale of the document
ProjectFileResolver Files uploaded to the project (assets(file) in templates); none by default
plugins A pluggy manager; create_manager() loads plugins of the dsw_templating_plugins entry point

Plugins implement the hooks of dsw.templating.plugins.specs (marked with dsw.templating.hookimpl); steps they provide are registered with register_plugin_steps(pm).

dsw.templating.pot extracts translatable messages of Jinja files into a POT file, and enrich_context_config(context, ContextDefaults()) adds to ctx.config what the document worker adds (service information and fallbacks for missing branding).

Documentation for template developers

License

This project is licensed under the Apache License v2.0 - see the LICENSE file for more details.

Metadata

Release files for dsw-templating 5.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dsw-templating 5.0.0
File Size Uploaded Provenance Actions
dsw_templating-5.0.0.tar.gz 92.3 kB With provenance Details for dsw_templating-5.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dsw-templating 5.0.0
File Interpreter ABI Platform Actions
dsw_templating-5.0.0-py3-none-any.whl Python 3 none any Details for dsw_templating-5.0.0-py3-none-any.whl

Total release size: 145.3 kB

Release files / dsw_templating-5.0.0.tar.gz

Download URL dsw_templating-5.0.0.tar.gz
Size 92.3 kB
Tags Source
SHA-256 checksum
How to use checksums
da126ed51f08391c944a86aaafa68220b6a2e4ddecdf142a140a0a34025d1a33
BLAKE2b-256 checksum
How to use checksums
5e0b6240f0324353c1bd500f03592847a04af3312c21c3d10fe593d70d1b3768
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / dsw_templating-5.0.0-py3-none-any.whl

Download URL dsw_templating-5.0.0-py3-none-any.whl
Size 53.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cafe8845c084b5fa7359b3569c4cb9c398173d8268dfc368fd1ae2fae36e5780
BLAKE2b-256 checksum
How to use checksums
ae31e1e450ad4f11a844d4fd958ea98fed2416b45d75aebebd52be9d674b5ecd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for dsw-templating 5.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dsw_templating-5.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

5.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page