Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0082.py @ 3877:00212260f659
plugin XEP-0420: Implementation of Stanza Content Encryption:
Includes implementation of XEP-0082 (XMPP date and time profiles) and tests for both new plugins.
Everything is type checked, linted, format checked and unit tested.
Adds new dependency xmlschema.
fix 377
author | Syndace <me@syndace.dev> |
---|---|
date | Tue, 23 Aug 2022 12:04:11 +0200 |
parents | |
children | 46930301f0c1 |
comparison
equal
deleted
inserted
replaced
3876:e3c1f4736ab2 | 3877:00212260f659 |
---|---|
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 # Type-check with `mypy --strict` | |
21 # Lint with `pylint` | |
22 | |
23 from sat.core.constants import Const as C | |
24 from sat.core.i18n import D_ | |
25 from sat.core.sat_main import SAT | |
26 from sat.tools import datetime | |
27 | |
28 | |
29 __all__ = [ # pylint: disable=unused-variable | |
30 "PLUGIN_INFO", | |
31 "XEP_0082" | |
32 ] | |
33 | |
34 | |
35 PLUGIN_INFO = { | |
36 C.PI_NAME: "XMPP Date and Time Profiles", | |
37 C.PI_IMPORT_NAME: "XEP-0082", | |
38 C.PI_TYPE: C.PLUG_TYPE_MISC, | |
39 C.PI_PROTOCOLS: [ "XEP-0082" ], | |
40 C.PI_DEPENDENCIES: [], | |
41 C.PI_RECOMMENDATIONS: [], | |
42 C.PI_MAIN: "XEP_0082", | |
43 C.PI_HANDLER: "no", | |
44 C.PI_DESCRIPTION: D_("Date and Time Profiles for XMPP"), | |
45 } | |
46 | |
47 | |
48 class XEP_0082: # pylint: disable=invalid-name | |
49 """ | |
50 Implementation of the date and time profiles specified in XEP-0082 using Python's | |
51 datetime module. The legacy format described in XEP-0082 section "4. Migration" is not | |
52 supported. Reexports of the functions in :mod:`sat.tools.datetime`. | |
53 | |
54 This is a passive plugin, i.e. it doesn't hook into any triggers to process stanzas | |
55 actively, but offers API for other plugins to use. | |
56 """ | |
57 | |
58 def __init__(self, sat: SAT) -> None: | |
59 """ | |
60 @param sat: The SAT instance. | |
61 """ | |
62 | |
63 format_date = staticmethod(datetime.format_date) | |
64 parse_date = staticmethod(datetime.parse_date) | |
65 format_datetime = staticmethod(datetime.format_datetime) | |
66 parse_datetime = staticmethod(datetime.parse_datetime) | |
67 format_time = staticmethod(datetime.format_time) | |
68 parse_time = staticmethod(datetime.parse_time) |