跳转到主要内容

用于重写模板文件部分(DTML,ZPT)的工具。

项目描述

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

用于重写模板文件部分(DTML,ZPT和XPT)的工具。

初始用途案例是拥有一个可插拔的系统,用于将模板中的Python 2表达式转换为Python 3。

此软件包在Python 3.6至3.10上运行。

需求

为了使重写正常工作,需要为具有无空格的attr="value"结构的属性进行重写,否则值将丢失。

注意事项

  • 在重写过程中,HTML注释中的双横线将被移除,因为 Zope 4 中的 Chameleon 引擎(以及实际规范)对此非常严格。

  • 底层的 lib2to3 并没有考虑到 Python 3 中不再提供 cmp 函数。

  • 该工具将 Python 2 转换为 Python 3,这意味着代码可能不再与 Python 2 兼容。对于这些边缘情况,需要手动更改才能使其与两个版本兼容。

开发 gocept.template_rewrite

作者:

gocept <mail@gocept.com>

问题:

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

源代码:

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

当前变更日志:

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

安装:

pip3 install gocept.template_rewrite

运行测试:

$ tox

gocept.template_rewrite 变更日志

1.1 (2022-04-29)

  • 将用于 HTML 属性的单引号转换为双引号。(#25)

  • 添加对 Python 3.9 和 3.10 的支持。

  • 确保与 pytest >= 6.0 兼容。

  • 使用 GHA 作为 CI 系统。

1.0 (2020-04-07)

  • 在解析页面模板时遇到问题的情况下,打印错误的精确位置。

  • 添加参数 –collect-errors,该参数将继续解析所有给定的文件并打印所有找到的解析错误,但如果找到错误则退出并显示错误,不会替换任何文件。这替代了早期版本中存在的 –only-show-errors 参数。这允许在重写之前创建一个要修复的错误完整列表。

  • 添加更多注意事项的说明。

  • 文件发现现在还包括以 .xpt 为文件扩展名的 TrustedFSPageTemplate 文件。

项目详情


下载文件

下载您平台的文件。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源分发

gocept.template_rewrite-1.1.tar.gz (16.5 kB 查看哈希)

上传时间

构建分发

gocept.template_rewrite-1.1-py3-none-any.whl (22.1 kB 查看哈希)

上传时间 Python 3

支持