Commit babc3bb4 authored by Emmanuel Gil Peyrot's avatar Emmanuel Gil Peyrot
Browse files

structs: Start typing some dataclasses

parent d4e20e0d
Pipeline #5390 canceled with stages
......@@ -17,7 +17,9 @@
import time
import random
from dataclasses import dataclass
from collections import namedtuple
from typing import Dict, Optional
from gi.repository import Soup
from gi.repository import Gio
......@@ -40,22 +42,42 @@ from nbxmpp.const import StatusCode
from nbxmpp.const import PresenceType
from nbxmpp.const import LOCATION_DATA
from nbxmpp.const import AdHocStatus
from nbxmpp.const import InviteType
StanzaHandler = namedtuple('StanzaHandler',
'name callback typ ns xmlns priority')
StanzaHandler.__new__.__defaults__ = ('', '', None, 50)
CommonResult = namedtuple('CommonResult', 'jid')
CommonResult.__new__.__defaults__ = (None,)
InviteData = namedtuple('InviteData',
'muc from_ reason password type continued thread')
DeclineData = namedtuple('DeclineData', 'muc from_ reason')
class CommonResult:
jid: Optional[JID] = None
class InviteData:
muc: JID
from_: JID
reason: str
password: str
type: InviteType
continued: bool
thread: str
class DeclineData:
muc: JID
from_: JID
reason: str
CaptchaData = namedtuple('CaptchaData', 'form bob_data')
BobData = namedtuple('BobData', 'algo hash_ max_age data cid type')
class BobData:
algo: str
hash_: str
max_age: int
data: bytes
cid: str
type: str
VoiceRequest = namedtuple('VoiceRequest', 'form jid nick')
......@@ -68,7 +90,10 @@ MucDestroyed.__new__.__defaults__ = (None, None, None)
MucConfigResult = namedtuple('MucConfigResult', 'jid form')
MucConfigResult.__new__.__defaults__ = (None,)
AffiliationResult = namedtuple('AffiliationResult', 'jid users')
class AffiliationResult:
jid: JID
users: Dict[JID, Dict[str, Optional[str]]]
EntityCapsData = namedtuple('EntityCapsData', 'hash node ver')
EntityCapsData.__new__.__defaults__ = (None, None, None)
......@@ -86,9 +111,16 @@ PubSubConfigResult = namedtuple('PubSubConfigResult', 'jid node form')
PubSubPublishResult = namedtuple('PubSubPublishResult', 'jid node id')
MoodData = namedtuple('MoodData', 'mood text')
class MoodData:
mood: str
text: str
ActivityData = namedtuple('ActivityData', 'activity subactivity text')
class ActivityData:
activity: str
subactivity: str
text: str
LocationData = namedtuple('LocationData', LOCATION_DATA)
LocationData.__new__.__defaults__ = (None,) * len(LocationData._fields)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment