From 672174fb23a8c5310f28a78fd461f7746191f064 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 31 Aug 2022 13:18:56 +0200 Subject: [PATCH] tools: renamed module `sat.tools.datetime` to `date.tools.xmpp_datetime` to avoid conflict with Python's standard lib --- sat/plugins/plugin_xep_0082.py | 16 ++++++++-------- sat/tools/utils.py | 7 +++++-- sat/tools/{datetime.py => xmpp_datetime.py} | 0 3 files changed, 13 insertions(+), 10 deletions(-) rename sat/tools/{datetime.py => xmpp_datetime.py} (100%) diff --git a/sat/plugins/plugin_xep_0082.py b/sat/plugins/plugin_xep_0082.py index 9bd9ae2f..9d964439 100644 --- a/sat/plugins/plugin_xep_0082.py +++ b/sat/plugins/plugin_xep_0082.py @@ -23,7 +23,7 @@ from sat.core.constants import Const as C from sat.core.i18n import D_ from sat.core.sat_main import SAT -from sat.tools import datetime +from sat.tools import xmpp_datetime __all__ = [ # pylint: disable=unused-variable @@ -49,7 +49,7 @@ class XEP_0082: # pylint: disable=invalid-name """ Implementation of the date and time profiles specified in XEP-0082 using Python's datetime module. The legacy format described in XEP-0082 section "4. Migration" is not - supported. Reexports of the functions in :mod:`sat.tools.datetime`. + supported. Reexports of the functions in :mod:`sat.tools.xmpp_datetime`. This is a passive plugin, i.e. it doesn't hook into any triggers to process stanzas actively, but offers API for other plugins to use. @@ -60,9 +60,9 @@ class XEP_0082: # pylint: disable=invalid-name @param sat: The SAT instance. """ - format_date = staticmethod(datetime.format_date) - parse_date = staticmethod(datetime.parse_date) - format_datetime = staticmethod(datetime.format_datetime) - parse_datetime = staticmethod(datetime.parse_datetime) - format_time = staticmethod(datetime.format_time) - parse_time = staticmethod(datetime.parse_time) + format_date = staticmethod(xmpp_datetime.format_date) + parse_date = staticmethod(xmpp_datetime.parse_date) + format_datetime = staticmethod(xmpp_datetime.format_datetime) + parse_datetime = staticmethod(xmpp_datetime.parse_datetime) + format_time = staticmethod(xmpp_datetime.format_time) + parse_time = staticmethod(xmpp_datetime.parse_time) diff --git a/sat/tools/utils.py b/sat/tools/utils.py index e6bdfe44..2f9cb368 100644 --- a/sat/tools/utils.py +++ b/sat/tools/utils.py @@ -34,7 +34,7 @@ from twisted.python import procutils, failure from twisted.internet import defer from sat.core.constants import Const as C from sat.core.log import getLogger -from sat.tools.datetime import format_date, format_datetime +from sat.tools import xmpp_datetime log = getLogger(__name__) @@ -157,7 +157,10 @@ def xmpp_date( datetime.timezone.utc ) - return format_datetime(dtime) if with_time else format_date(dtime.date()) + return ( + xmpp_datetime.format_datetime(dtime) if with_time + else xmpp_datetime.format_date(dtime.date()) + ) def generatePassword(vocabulary=None, size=20): diff --git a/sat/tools/datetime.py b/sat/tools/xmpp_datetime.py similarity index 100% rename from sat/tools/datetime.py rename to sat/tools/xmpp_datetime.py