Skip to main content

gocept.template_rewrite

https://img.shields.io/pypi/v/gocept.template_rewrite.svg https://img.shields.io/pypi/pyversions/gocept.template_rewrite.svg https://github.com/gocept/gocept.template_rewrite/workflows/tests/badge.svg https://coveralls.io/repos/github/gocept/gocept.template_rewrite/badge.svg

A tool to rewrite parts of template files (DTML, ZPT and XPT).

The initial use case is to have a pluggable system to convert Python 2 expressions in templates to Python 3.

This package runs on Python 3.6 up to 3.10.

Requirements

For the rewrite to work properly, it is necessary to have this structure attr="value" for attributes in tags with no whitespaces around the =, as otherwise the values will get lost.

Caveats

  • During rewrite double hyphens within HTML-comments are removed as the Chameleon engine in Zope 4 (and the actual specification) is very strict about it.

  • The underlying lib2to3 does not take into account, that the cmp function is no longer available in Python 3.

  • This tool converts Python 2 to Python 3 - that means the code may not be compatible with Python 2 any more. For these edge cases manual changes are required to make it compatible with both versions.

Developing gocept.template_rewrite

Author:

gocept <mail@gocept.com>

Issues:

https://github.com/gocept/gocept.template_rewrite/issues

Source code:

https://github.com/gocept/gocept.template_rewrite

Current change log:

https://raw.githubusercontent.com/gocept/gocept.template_rewrite/master/CHANGES.rst

Installation:

pip3 install gocept.template_rewrite

Run the tests:

$ tox

Change log for gocept.template_rewrite

1.1 (2022-04-29)

  • Convert single quotes used for HTML attributes into double quotes. (#25)

  • Add support for Python 3.9 and 3.10.

  • Ensure compatibility with pytest >= 6.0.

  • Use GHA as CI system.

1.0 (2020-04-07)

  • Print exact location of error in case of problems parsing Page Templates.

  • Add parameter –collect-errors that continues to parse all given files and prints all found parsing errors but exits with an error and does not replace any files if an error was found. This replaces the argument –only-show-errors present in earlier versions. This allows to create a full list of errors to be fixed before a rewrite is possible.

  • Add notes about more caveats.

  • File discovery now also includes TrustedFSPageTemplate files, which are registered with the file ending .xpt.

Release files for gocept.template-rewrite 1.1

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

Source distribution (sdist)

Source distribution for gocept.template-rewrite 1.1
File Size Uploaded
gocept.template_rewrite-1.1.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gocept.template-rewrite 1.1
File Interpreter ABI Platform
gocept.template_rewrite-1.1-py3-none-any.whl Python 3 none any Details

Total release size: 38.6 kB

Release files / gocept.template_rewrite-1.1.tar.gz

Download URL gocept.template_rewrite-1.1.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
bfb391cb5765a5098dc642307edba4e96a48b3a0551e21ee33702431c07892d6
BLAKE2b-256 checksum
How to use checksums
577e0a2fd227fdec617820f2a00baee17b49448495a9d3be67468dfebe449777
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.12

Release files / gocept.template_rewrite-1.1-py3-none-any.whl

Download URL gocept.template_rewrite-1.1-py3-none-any.whl
Size 22.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68e29fca05f2a115b8299889c06298484334964f550d9f1304f6f67a1b7ec671
BLAKE2b-256 checksum
How to use checksums
955b4e7e6014c74e0589cf663084627828182671ff0a1a36f1125eaeb6616d06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.12

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files

1.0

2 release files

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