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 4.35.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 4.35.0
File Size Uploaded Provenance
dsw_templating-4.35.0.tar.gz 84.3 kB With provenance Details

Built distribution (wheel)

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

Total release size: 136.0 kB

Release files / dsw_templating-4.35.0.tar.gz

Download URL dsw_templating-4.35.0.tar.gz
Size 84.3 kB
Tags Source
SHA-256 checksum
How to use checksums
99e2fa245b92466547146c47ee9489fbd926cbd1881acd83e3f0f46b9ac537c7
BLAKE2b-256 checksum
How to use checksums
b1b8375fe6b0fff759fda51aed74c55cf046689d3519ce801e2819d61bdda56c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 6, 2026.

Transparency log

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

Download URL dsw_templating-4.35.0-py3-none-any.whl
Size 51.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a68f308c7b548a79c48ad6c09e39709df351d3527818197d6aefe17b56a6f951
BLAKE2b-256 checksum
How to use checksums
ed4e7cd232d0159091203fbdc4417c614295cf6c4cdc976db837c07c6cb9883c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 6, 2026.

Transparency log

Security for dsw-templating 4.35.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dsw_templating-4.35.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 Oct 6, 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

4.35.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