forked from pool/python-python-pptx
Accepting request 1158173 from home:mcalabkova:branches:devel:languages:python
- Add patch utc.patch to fix the behavior on Python 3.12 OBS-URL: https://build.opensuse.org/request/show/1158173 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-python-pptx?expand=0&rev=9
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Mar 15 09:18:12 UTC 2024 - Markéta Machová <mmachova@suse.com>
|
||||||
|
|
||||||
|
- Add patch utc.patch to fix the behavior on Python 3.12
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Dec 26 20:29:02 UTC 2023 - Dirk Müller <dmueller@suse.com>
|
Tue Dec 26 20:29:02 UTC 2023 - Dirk Müller <dmueller@suse.com>
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package python-python-pptx
|
# spec file for package python-python-pptx
|
||||||
#
|
#
|
||||||
# Copyright (c) 2023 SUSE LLC
|
# Copyright (c) 2024 SUSE LLC
|
||||||
# Copyright (c) 2021, Martin Hauke <mardnh@gmx.de>
|
# Copyright (c) 2021, Martin Hauke <mardnh@gmx.de>
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
|
||||||
Name: python-python-pptx
|
Name: python-python-pptx
|
||||||
Version: 0.6.23
|
Version: 0.6.23
|
||||||
Release: 0
|
Release: 0
|
||||||
@@ -25,6 +24,8 @@ Summary: Generate and manipulate Open XML PowerPoint (pptx) files
|
|||||||
License: MIT
|
License: MIT
|
||||||
URL: http://github.com/scanny/python-pptx
|
URL: http://github.com/scanny/python-pptx
|
||||||
Source: https://files.pythonhosted.org/packages/source/p/python-pptx/python-pptx-%{version}.tar.gz
|
Source: https://files.pythonhosted.org/packages/source/p/python-pptx/python-pptx-%{version}.tar.gz
|
||||||
|
# PATCH-FIX-UPSTREAM https://github.com/scanny/python-pptx/pull/957 Use UTC-aware datetime objects
|
||||||
|
Patch: utc.patch
|
||||||
BuildRequires: %{python_module setuptools}
|
BuildRequires: %{python_module setuptools}
|
||||||
BuildRequires: python-rpm-macros
|
BuildRequires: python-rpm-macros
|
||||||
# SECTION test requirements
|
# SECTION test requirements
|
||||||
@@ -46,7 +47,7 @@ BuildArch: noarch
|
|||||||
Generate and manipulate Open XML PowerPoint (.pptx) files.
|
Generate and manipulate Open XML PowerPoint (.pptx) files.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n python-pptx-%{version}
|
%autosetup -p1 -n python-pptx-%{version}
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%python_build
|
%python_build
|
||||||
|
88
utc.patch
Normal file
88
utc.patch
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
Index: python-pptx-0.6.23/features/steps/coreprops.py
|
||||||
|
===================================================================
|
||||||
|
--- python-pptx-0.6.23.orig/features/steps/coreprops.py
|
||||||
|
+++ python-pptx-0.6.23/features/steps/coreprops.py
|
||||||
|
@@ -6,7 +6,7 @@ Gherkin step implementations for core pr
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
-from datetime import datetime, timedelta
|
||||||
|
+from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
|
from behave import given, when, then
|
||||||
|
|
||||||
|
@@ -67,7 +67,7 @@ def step_then_a_core_props_part_with_def
|
||||||
|
assert core_props.revision == 1
|
||||||
|
# core_props.modified only stores time with seconds resolution, so
|
||||||
|
# comparison needs to be a little loose (within two seconds)
|
||||||
|
- modified_timedelta = datetime.utcnow() - core_props.modified
|
||||||
|
+ modified_timedelta = datetime.now(timezone.utc) - core_props.modified
|
||||||
|
max_expected_timedelta = timedelta(seconds=2)
|
||||||
|
assert modified_timedelta < max_expected_timedelta
|
||||||
|
|
||||||
|
Index: python-pptx-0.6.23/pptx/parts/coreprops.py
|
||||||
|
===================================================================
|
||||||
|
--- python-pptx-0.6.23.orig/pptx/parts/coreprops.py
|
||||||
|
+++ python-pptx-0.6.23/pptx/parts/coreprops.py
|
||||||
|
@@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
"""Core properties part, corresponds to ``/docProps/core.xml`` part in package."""
|
||||||
|
|
||||||
|
-from datetime import datetime
|
||||||
|
+from datetime import datetime, timezone
|
||||||
|
|
||||||
|
from pptx.opc.constants import CONTENT_TYPE as CT
|
||||||
|
from pptx.opc.package import XmlPart
|
||||||
|
@@ -27,7 +27,7 @@ class CorePropertiesPart(XmlPart):
|
||||||
|
core_props.title = "PowerPoint Presentation"
|
||||||
|
core_props.last_modified_by = "python-pptx"
|
||||||
|
core_props.revision = 1
|
||||||
|
- core_props.modified = datetime.utcnow()
|
||||||
|
+ core_props.modified = datetime.now(timezone.utc)
|
||||||
|
return core_props
|
||||||
|
|
||||||
|
@property
|
||||||
|
Index: python-pptx-0.6.23/tests/parts/test_coreprops.py
|
||||||
|
===================================================================
|
||||||
|
--- python-pptx-0.6.23.orig/tests/parts/test_coreprops.py
|
||||||
|
+++ python-pptx-0.6.23/tests/parts/test_coreprops.py
|
||||||
|
@@ -4,7 +4,7 @@
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
-from datetime import datetime, timedelta
|
||||||
|
+from datetime import datetime, timedelta, timezone
|
||||||
|
|
||||||
|
from pptx.opc.constants import CONTENT_TYPE as CT
|
||||||
|
from pptx.oxml.coreprops import CT_CoreProperties
|
||||||
|
@@ -55,7 +55,7 @@ class DescribeCorePropertiesPart(object)
|
||||||
|
assert core_props.revision == 1
|
||||||
|
# core_props.modified only stores time with seconds resolution, so
|
||||||
|
# comparison needs to be a little loose (within two seconds)
|
||||||
|
- modified_timedelta = datetime.utcnow() - core_props.modified
|
||||||
|
+ modified_timedelta = datetime.now(timezone.utc) - core_props.modified
|
||||||
|
max_expected_timedelta = timedelta(seconds=2)
|
||||||
|
assert modified_timedelta < max_expected_timedelta
|
||||||
|
|
||||||
|
@@ -70,7 +70,7 @@ class DescribeCorePropertiesPart(object)
|
||||||
|
)
|
||||||
|
def date_prop_get_fixture(self, request, core_properties):
|
||||||
|
prop_name, expected_datetime = request.param
|
||||||
|
- return core_properties, prop_name, expected_datetime
|
||||||
|
+ return core_properties, prop_name, expected_datetime.astimezone() if expected_datetime is not None else None
|
||||||
|
|
||||||
|
@pytest.fixture(
|
||||||
|
params=[
|
||||||
|
Index: python-pptx-0.6.23/pptx/oxml/coreprops.py
|
||||||
|
===================================================================
|
||||||
|
--- python-pptx-0.6.23.orig/pptx/oxml/coreprops.py
|
||||||
|
+++ python-pptx-0.6.23/pptx/oxml/coreprops.py
|
||||||
|
@@ -247,7 +247,7 @@ class CT_CoreProperties(BaseOxmlElement)
|
||||||
|
dt = None
|
||||||
|
for tmpl in templates:
|
||||||
|
try:
|
||||||
|
- dt = datetime.strptime(parseable_part, tmpl)
|
||||||
|
+ dt = datetime.strptime(parseable_part, tmpl).astimezone()
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
|
if dt is None:
|
Reference in New Issue
Block a user