summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2020-04-19 18:34:02 +0200
committerMichał Górny <mgorny@gentoo.org>2020-04-19 18:42:00 +0200
commit80cd154ee9faf45101dfc01dfd428840050e777d (patch)
treea4f7a42490ae309b24715cba59f98475e60df249 /dev-python
parentdev-python/arrow: Bump to 0.15.5, py3.8 (diff)
downloadgentoo-80cd154ee9faf45101dfc01dfd428840050e777d.tar.gz
gentoo-80cd154ee9faf45101dfc01dfd428840050e777d.tar.bz2
gentoo-80cd154ee9faf45101dfc01dfd428840050e777d.zip
dev-python/jinja2-time: fix arrow compat, py3.7 & py3.8
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python')
-rw-r--r--dev-python/jinja2-time/files/jinja2-time-0.2.0-arrow-compat.patch38
-rw-r--r--dev-python/jinja2-time/jinja2-time-0.2.0.ebuild18
2 files changed, 46 insertions, 10 deletions
diff --git a/dev-python/jinja2-time/files/jinja2-time-0.2.0-arrow-compat.patch b/dev-python/jinja2-time/files/jinja2-time-0.2.0-arrow-compat.patch
new file mode 100644
index 000000000000..04d2993c453f
--- /dev/null
+++ b/dev-python/jinja2-time/files/jinja2-time-0.2.0-arrow-compat.patch
@@ -0,0 +1,38 @@
+From aa4af9af0a0a5111a8ad21bc1b43bbdb586ee8af Mon Sep 17 00:00:00 2001
+From: Vincent Bernat <vincent@bernat.ch>
+Date: Sun, 3 Nov 2019 07:48:08 +0100
+Subject: [PATCH] Use shift() instead of replace() to modify dates
+
+Previously, the `replace()` method from arrow was shifting the date
+when the arguments were using the plural form. Since Arrow 0.9.0, this
+has been deprecated in favor of a `shift()` method. Arrow 0.14.5
+completely removed the ability for `replace()` to shift dates. This
+leads to errors like `AttributeError: unknown attribute: "hours"` when
+using plural form.
+
+This commit replace the use of `replace()` by `shift()` since the
+intent is always to shift the current date.
+---
+ jinja2_time/jinja2_time.py | 6 +++---
+ setup.py | 4 ++--
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/jinja2_time/jinja2_time.py b/jinja2_time/jinja2_time.py
+index ce713cb..717c8a0 100755
+--- a/jinja2_time/jinja2_time.py
++++ b/jinja2_time/jinja2_time.py
+@@ -19,11 +19,11 @@ def _datetime(self, timezone, operator, offset, datetime_format):
+ d = arrow.now(timezone)
+
+ # Parse replace kwargs from offset and include operator
+- replace_params = {}
++ shift_params = {}
+ for param in offset.split(','):
+ interval, value = param.split('=')
+- replace_params[interval.strip()] = float(operator + value.strip())
+- d = d.replace(**replace_params)
++ shift_params[interval.strip()] = float(operator + value.strip())
++ d = d.shift(**shift_params)
+
+ if datetime_format is None:
+ datetime_format = self.environment.datetime_format
diff --git a/dev-python/jinja2-time/jinja2-time-0.2.0.ebuild b/dev-python/jinja2-time/jinja2-time-0.2.0.ebuild
index eed27c8c8b51..ece803b2e17c 100644
--- a/dev-python/jinja2-time/jinja2-time-0.2.0.ebuild
+++ b/dev-python/jinja2-time/jinja2-time-0.2.0.ebuild
@@ -1,9 +1,9 @@
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-EAPI=6
+EAPI=7
-PYTHON_COMPAT=( python3_6 )
+PYTHON_COMPAT=( python3_{6,7,8} )
inherit distutils-r1
DESCRIPTION="Jinja2 Extension for Dates and Times"
@@ -13,15 +13,13 @@ SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="amd64 ~x86"
-IUSE="test"
-RESTRICT="!test? ( test )"
RDEPEND="dev-python/arrow[${PYTHON_USEDEP}]
dev-python/jinja[${PYTHON_USEDEP}]"
-DEPEND="test? ( dev-python/pytest[${PYTHON_USEDEP}]
- dev-python/freezegun[${PYTHON_USEDEP}]
- ${RDEPEND} )"
+BDEPEND="test? ( dev-python/freezegun[${PYTHON_USEDEP}] )"
-python_test() {
- py.test || die
-}
+distutils_enable_tests pytest
+
+PATCHES=(
+ "${FILESDIR}"/${P}-arrow-compat.patch
+)