comparison libervia/backend/plugins/plugin_xep_0082.py @ 4071:4b842c1fb686

refactoring: renamed `sat` package to `libervia.backend`
author Goffi <goffi@goffi.org>
date Fri, 02 Jun 2023 11:49:51 +0200
parents sat/plugins/plugin_xep_0082.py@8289ac1b34f4
children 040095a5dc7f
comparison
equal deleted inserted replaced
4070:d10748475025 4071:4b842c1fb686
1 #!/usr/bin/env python3
2
3 # Libervia plugin for XMPP Date and Time Profile formatting and parsing with Python's
4 # datetime package
5 # Copyright (C) 2022-2022 Tim Henkes (me@syndace.dev)
6
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
16
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 from libervia.backend.core.constants import Const as C
21 from libervia.backend.core.i18n import D_
22 from libervia.backend.core.sat_main import SAT
23 from libervia.backend.tools import xmpp_datetime
24
25
26 __all__ = [ # pylint: disable=unused-variable
27 "PLUGIN_INFO",
28 "XEP_0082"
29 ]
30
31
32 PLUGIN_INFO = {
33 C.PI_NAME: "XMPP Date and Time Profiles",
34 C.PI_IMPORT_NAME: "XEP-0082",
35 C.PI_TYPE: C.PLUG_TYPE_MISC,
36 C.PI_PROTOCOLS: [ "XEP-0082" ],
37 C.PI_DEPENDENCIES: [],
38 C.PI_RECOMMENDATIONS: [],
39 C.PI_MAIN: "XEP_0082",
40 C.PI_HANDLER: "no",
41 C.PI_DESCRIPTION: D_("Date and Time Profiles for XMPP"),
42 }
43
44
45 class XEP_0082: # pylint: disable=invalid-name
46 """
47 Implementation of the date and time profiles specified in XEP-0082 using Python's
48 datetime module. The legacy format described in XEP-0082 section "4. Migration" is not
49 supported. Reexports of the functions in :mod:`sat.tools.xmpp_datetime`.
50
51 This is a passive plugin, i.e. it doesn't hook into any triggers to process stanzas
52 actively, but offers API for other plugins to use.
53 """
54
55 def __init__(self, sat: SAT) -> None:
56 """
57 @param sat: The SAT instance.
58 """
59
60 format_date = staticmethod(xmpp_datetime.format_date)
61 parse_date = staticmethod(xmpp_datetime.parse_date)
62 format_datetime = staticmethod(xmpp_datetime.format_datetime)
63 parse_datetime = staticmethod(xmpp_datetime.parse_datetime)
64 format_time = staticmethod(xmpp_datetime.format_time)
65 parse_time = staticmethod(xmpp_datetime.parse_time)