Skip to main content

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

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gocept.template_rewrite-1.1.tar.gz (16.5 kB view hashes)

Uploaded Source

Built Distribution

gocept.template_rewrite-1.1-py3-none-any.whl (22.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page