diff options
Diffstat (limited to 'gis/OWSLib/remove_dependency_on_pytz.patch')
-rw-r--r-- | gis/OWSLib/remove_dependency_on_pytz.patch | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/gis/OWSLib/remove_dependency_on_pytz.patch b/gis/OWSLib/remove_dependency_on_pytz.patch new file mode 100644 index 0000000000..85d4f6ad43 --- /dev/null +++ b/gis/OWSLib/remove_dependency_on_pytz.patch @@ -0,0 +1,103 @@ +diff --git a/etc/RPM/python-owslib.spec b/etc/RPM/python-owslib.spec +index 96f8599de..8dfad75df 100644 +--- a/etc/RPM/python-owslib.spec ++++ b/etc/RPM/python-owslib.spec +@@ -25,7 +25,7 @@ BuildRequires: python-devel + BuildRequires: python-setuptools + BuildRequires: fdupes + Requires: python +-Requires: python-dateutil python-pytz ++Requires: python-dateutil + + %description + OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models. +diff --git a/owslib/util.py b/owslib/util.py +index 7894aa729..c715b3ce0 100644 +--- a/owslib/util.py ++++ b/owslib/util.py +@@ -12,8 +12,7 @@ + import sys + from collections import OrderedDict + from dateutil import parser +-from datetime import datetime, timedelta +-import pytz ++from datetime import datetime, timedelta, tzinfo + from owslib.etree import etree, ParseError + from owslib.namespaces import Namespaces + from urllib.parse import urlsplit, urlencode, urlparse, parse_qs, urlunparse, parse_qsl +@@ -38,6 +37,20 @@ class ServiceException(Exception): + pass + + ++# Allows marking timestamps as UTC without pulling in all of Pytz ++class TimeZone_UTC(tzinfo): ++ def tzname(self, dt): ++ return "UTC" ++ ++ def utcoffset(self, dt): ++ return timedelta(0) ++ ++ def dst(self, dt): ++ return timedelta(0) ++ ++tz_utc = TimeZone_UTC() ++ ++ + # http://stackoverflow.com/questions/6256183/combine-two-dictionaries-of-dictionaries-python + def dict_union(d1, d2): + return dict((x, (dict_union(d1.get(x, {}), d2[x]) if isinstance(d2.get(x), dict) else d2.get(x, d1.get(x)))) +@@ -649,8 +662,7 @@ def extract_time(element): + except Exception: + att = testXMLValue(element.attrib.get('indeterminatePosition'), True) + if att and att == 'now': +- dt = datetime.utcnow() +- dt.replace(tzinfo=pytz.utc) ++ dt = datetime.utcnow().replace(tzinfo=tz_utc) + else: + dt = None + return dt +diff --git a/requirements.txt b/requirements.txt +index c1b2c09bd..1531aa42f 100644 +--- a/requirements.txt ++++ b/requirements.txt +@@ -1,6 +1,5 @@ + dataclasses; python_version < '3.7' + lxml + python-dateutil>=1.5 +-pytz + pyyaml + requests>=1.0 +diff --git a/tests/doctests/sml_52n_network.txt b/tests/doctests/sml_52n_network.txt +index 010fbb6b5..94add7ddc 100644 +--- a/tests/doctests/sml_52n_network.txt ++++ b/tests/doctests/sml_52n_network.txt +@@ -3,7 +3,6 @@ Imports + >>> from tests.utils import resource_file + >>> from owslib.swe.sensor.sml import SensorML + >>> from dateutil import parser +- >>> import pytz + + Initialize + +diff --git a/tests/doctests/sml_ndbc_station.txt b/tests/doctests/sml_ndbc_station.txt +index bd2ecf3af..bda0e559a 100644 +--- a/tests/doctests/sml_ndbc_station.txt ++++ b/tests/doctests/sml_ndbc_station.txt +@@ -3,7 +3,7 @@ Imports + >>> from tests.utils import resource_file + >>> from owslib.swe.sensor.sml import SensorML + >>> from dateutil import parser +- >>> import pytz ++ >>> from owslib.util import TimeZone_UTC + + Initialize + +@@ -104,7 +104,7 @@ History + 2 + + >>> event = his[0] +- >>> parser.parse(event.date).replace(tzinfo=pytz.utc).isoformat() ++ >>> parser.parse(event.date).replace(tzinfo=TimeZone_UTC()).isoformat() + '2010-01-12T00:00:00+00:00' + >>> event.description + 'Deployment start event' |