diff options
author | mathieui <mathieui@mathieui.net> | 2020-12-10 19:20:23 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2020-12-10 19:22:40 +0100 |
commit | 95d40a3ca336a4e1b66c7ed287ec3f2ef92b201c (patch) | |
tree | ef3086be7313a8e61e51b7a3efed302d0e154cb0 /slixmpp/plugins/xep_0202 | |
parent | 010bf6dd70a44d9e9087336bc955a591ab9248b3 (diff) | |
download | slixmpp-95d40a3ca336a4e1b66c7ed287ec3f2ef92b201c.tar.gz slixmpp-95d40a3ca336a4e1b66c7ed287ec3f2ef92b201c.tar.bz2 slixmpp-95d40a3ca336a4e1b66c7ed287ec3f2ef92b201c.tar.xz slixmpp-95d40a3ca336a4e1b66c7ed287ec3f2ef92b201c.zip |
docs: update docstrings for sphinx conformity
Remove most references to timeout/callback/ifrom/timeout_callbacks args
Diffstat (limited to 'slixmpp/plugins/xep_0202')
-rw-r--r-- | slixmpp/plugins/xep_0202/stanza.py | 28 | ||||
-rw-r--r-- | slixmpp/plugins/xep_0202/time.py | 20 |
2 files changed, 17 insertions, 31 deletions
diff --git a/slixmpp/plugins/xep_0202/stanza.py b/slixmpp/plugins/xep_0202/stanza.py index 4c7a0229..e71ffe9c 100644 --- a/slixmpp/plugins/xep_0202/stanza.py +++ b/slixmpp/plugins/xep_0202/stanza.py @@ -23,6 +23,8 @@ class EntityTime(ElementBase): included. Example <time> stanzas: + :: + <iq type="result"> <time xmlns="urn:xmpp:time"> <utc>2011-07-03T11:37:12.234569</utc> @@ -31,18 +33,11 @@ class EntityTime(ElementBase): </iq> Stanza Interface: + :: + time -- The local time for the entity (updates utc and tzo). utc -- The UTC equivalent to local time. tzo -- The local timezone offset from UTC. - - Methods: - get_time -- Return local time datetime object. - set_time -- Set UTC and TZO fields. - del_time -- Remove both UTC and TZO fields. - get_utc -- Return datetime object of UTC time. - set_utc -- Set the UTC time. - get_tzo -- Return tzinfo object. - set_tzo -- Set the local timezone offset. """ name = 'time' @@ -55,9 +50,8 @@ class EntityTime(ElementBase): """ Set both the UTC and TZO fields given a time object. - Arguments: - value -- A datetime object or properly formatted - string equivalent. + :param value: A datetime object or properly formatted + string equivalent. """ date = value if not isinstance(value, dt.datetime): @@ -92,9 +86,8 @@ class EntityTime(ElementBase): """ Set the timezone offset from UTC. - Arguments: - value -- Either a tzinfo object or the number of - seconds (positive or negative) to offset. + :param value: Either a tzinfo object or the number of + seconds (positive or negative) to offset. """ time = xep_0082.time(offset=value) if xep_0082.parse(time).tzinfo == tzutc(): @@ -115,9 +108,8 @@ class EntityTime(ElementBase): """ Set the time in UTC. - Arguments: - value -- A datetime object or properly formatted - string equivalent. + :param value: A datetime object or properly formatted + string equivalent. """ date = value if not isinstance(value, dt.datetime): diff --git a/slixmpp/plugins/xep_0202/time.py b/slixmpp/plugins/xep_0202/time.py index 2b40dbb2..bec3a771 100644 --- a/slixmpp/plugins/xep_0202/time.py +++ b/slixmpp/plugins/xep_0202/time.py @@ -8,6 +8,9 @@ import logging +from typing import Optional + +from slixmpp import JID from slixmpp.stanza.iq import Iq from slixmpp.xmlstream import register_stanza_plugin from slixmpp.xmlstream.handler import Callback @@ -61,7 +64,7 @@ class XEP_0202(BasePlugin): def session_bind(self, jid): self.xmpp['xep_0030'].add_feature('urn:xmpp:time') - def _handle_time_request(self, iq): + def _handle_time_request(self, iq: Iq): """ Respond to a request for the local time. @@ -69,26 +72,17 @@ class XEP_0202(BasePlugin): during plugin configuration with a function that maps JIDs to times. - Arguments: - iq -- The Iq time request stanza. + :param iq: The Iq time request stanza. """ iq = iq.reply() iq['entity_time']['time'] = self.local_time(iq['to']) iq.send() - def get_entity_time(self, to, ifrom=None, **iqargs): + def get_entity_time(self, to: JID, ifrom: Optional[JID] = None, **iqargs): """ Request the time from another entity. - Arguments: - to -- JID of the entity to query. - ifrom -- Specifiy the sender's JID. - block -- If true, block and wait for the stanzas' reply. - timeout -- The time in seconds to block while waiting for - a reply. If None, then wait indefinitely. - callback -- Optional callback to execute when a reply is - received instead of blocking and waiting for - the reply. + :param to: JID of the entity to query. """ iq = self.xmpp.Iq() iq['type'] = 'get' |