diff options
author | Louis Sautier <sbraz@gentoo.org> | 2020-09-17 20:52:41 +0200 |
---|---|---|
committer | Louis Sautier <sbraz@gentoo.org> | 2020-09-17 21:05:24 +0200 |
commit | 09eaf73828ac4bc0794332448c2dd6144fb429e6 (patch) | |
tree | 365245d411aa0ff94c6b5bdfb0af27579cf6e0a8 /dev-python/tempita | |
parent | dev-cpp/eigen: bitbucket -> gitlab (diff) | |
download | gentoo-09eaf73828ac4bc0794332448c2dd6144fb429e6.tar.gz gentoo-09eaf73828ac4bc0794332448c2dd6144fb429e6.tar.bz2 gentoo-09eaf73828ac4bc0794332448c2dd6144fb429e6.zip |
dev-python/tempita: add python 3.9 support by removing cgi.escape
Package-Manager: Portage-3.0.7, Repoman-3.0.1
Signed-off-by: Louis Sautier <sbraz@gentoo.org>
Diffstat (limited to 'dev-python/tempita')
-rw-r--r-- | dev-python/tempita/files/tempita-0.5.3-cgi-escape.patch | 31 | ||||
-rw-r--r-- | dev-python/tempita/tempita-0.5.3-r3.ebuild | 52 |
2 files changed, 83 insertions, 0 deletions
diff --git a/dev-python/tempita/files/tempita-0.5.3-cgi-escape.patch b/dev-python/tempita/files/tempita-0.5.3-cgi-escape.patch new file mode 100644 index 000000000000..d411d28ced48 --- /dev/null +++ b/dev-python/tempita/files/tempita-0.5.3-cgi-escape.patch @@ -0,0 +1,31 @@ +diff --git a/tempita/__init__.py b/tempita/__init__.py +index 137ba2d..acc2fd9 100755 +--- a/tempita/__init__.py ++++ b/tempita/__init__.py +@@ -31,12 +31,12 @@ can use ``__name='tmpl.html'`` to set the name of the template. + If there are syntax errors ``TemplateError`` will be raised. + """ + +-import cgi + import os + import re + import sys + import tokenize + from cStringIO import StringIO ++from html import escape + from urllib import quote as url_quote + from tempita._looper import looper + from tempita.compat3 import bytes, basestring_, next, is_unicode, coerce_text +@@ -445,10 +445,10 @@ def html_quote(value, force=True): + if not isinstance(value, basestring_): + value = coerce_text(value) + if sys.version >= "3" and isinstance(value, bytes): +- value = cgi.escape(value.decode('latin1'), 1) ++ value = escape(value.decode('latin1'), 1) + value = value.encode('latin1') + else: +- value = cgi.escape(value, 1) ++ value = escape(value, 1) + if sys.version < "3": + if is_unicode(value): + value = value.encode('ascii', 'xmlcharrefreplace') diff --git a/dev-python/tempita/tempita-0.5.3-r3.ebuild b/dev-python/tempita/tempita-0.5.3-r3.ebuild new file mode 100644 index 000000000000..d455c913ca0a --- /dev/null +++ b/dev-python/tempita/tempita-0.5.3-r3.ebuild @@ -0,0 +1,52 @@ +# Copyright 1999-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( pypy3 python3_{6,7,8,9} ) +# The package uses pkg_resources +DISTUTILS_USE_SETUPTOOLS=manual + +inherit distutils-r1 + +MY_COMMIT="97392d008cc8" + +DESCRIPTION="A very small text templating language" +HOMEPAGE="https://pypi.org/project/Tempita/" +# Tests are not published on PyPI +SRC_URI="https://bitbucket.org/ianb/${PN}/get/${MY_COMMIT}.tar.gz -> ${P}-bitbucket.tar.gz" +S="${WORKDIR}/ianb-${PN}-${MY_COMMIT}" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux" +IUSE="test" +RESTRICT="!test? ( test )" + +RDEPEND="dev-python/setuptools[${PYTHON_USEDEP}]" +BDEPEND=" + dev-python/setuptools[${PYTHON_USEDEP}] + test? ( dev-python/pytest[${PYTHON_USEDEP}] ) +" + +PATCHES=( + "${FILESDIR}/${P}-pypy-tests.patch" + # cgi.escape has been removed in Python 3.9 + "${FILESDIR}/${P}-cgi-escape.patch" +) + +distutils_enable_sphinx docs + +python_prepare_all() { + # Remove reference to a non-existent CSS file + # in order to make sphinx use its default theme. + sed -i '/^html_style =/d' docs/conf.py || die + distutils-r1_python_prepare_all +} + +python_test() { + # We need to append to sys.path, otherwise pytest imports + # the module from ${S} (before it was 2to3'd) + pytest --import-mode=append -vv tests/test_template.txt docs/index.txt \ + || die "Tests failed with ${EPYTHON}" +} |