Commit b5ae2cd3 authored by Emmanuel Gil Peyrot's avatar Emmanuel Gil Peyrot

structs: Start typing some dataclasses

parent 93889f28
Pipeline #5391 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,55 +42,110 @@ 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 AdHocNoteType
from nbxmpp.const import InviteType
from nbxmpp.const import Role
from nbxmpp.const import Affiliation
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')
MucUserData = namedtuple('MucUserData', 'affiliation jid nick role actor reason')
MucUserData.__new__.__defaults__ = (None, None, None, None, None)
MucDestroyed = namedtuple('MucDestroyed', 'alternate reason password')
MucDestroyed.__new__.__defaults__ = (None, None, None)
class MucUserData:
affiliation: Affiliation
jid: JID
nick: Optional[str] = None
role: Role
actor: Optional[str] = None
reason: Optional[str] = None
class MucDestroyed:
alternate: Optional[JID] = None
reason: Optional[str] = None
password: Optional[str] = None
MucConfigResult = namedtuple('MucConfigResult', 'jid form')
MucConfigResult.__new__.__defaults__ = (None,)
AffiliationResult = namedtuple('AffiliationResult', 'jid users')
EntityCapsData = namedtuple('EntityCapsData', 'hash node ver')
EntityCapsData.__new__.__defaults__ = (None, None, None)
HTTPAuthData = namedtuple('HTTPAuthData', 'id method url body')
HTTPAuthData.__new__.__defaults__ = (None, None, None, None)
StanzaIDData = namedtuple('StanzaIDData', 'id by')
StanzaIDData.__new__.__defaults__ = (None, None)
class AffiliationResult:
jid: JID
users: Dict[JID, Dict[str, Optional[str]]]
class EntityCapsData:
hash: Optional[str] = None
node: Optional[str] = None
ver: Optional[str] = None
class HTTPAuthData:
id: Optional[str] = None
method: Optional[str] = None
url: Optional[str] = None
body: Optional[str] = None
class StanzaIDData:
id: str
by: str
PubSubEventData = namedtuple('PubSubEventData', 'node id item data deleted retracted purged')
PubSubEventData.__new__.__defaults__ = (None, None, None, False, False, False)
PubSubConfigResult = namedtuple('PubSubConfigResult', 'jid node form')
PubSubPublishResult = namedtuple('PubSubPublishResult', 'jid node id')
class PubSubPublishResult:
jid: JID
node: Optional[str] = None
id: Optional[str] = None
MoodData = namedtuple('MoodData', 'mood text')
class MoodData:
mood: str
text: Optional[str]
ActivityData = namedtuple('ActivityData', 'activity subactivity text')
class ActivityData:
activity: str
subactivity: Optional[str]
text: Optional[str]
LocationData = namedtuple('LocationData', LOCATION_DATA)
LocationData.__new__.__defaults__ = (None,) * len(LocationData._fields)
......@@ -96,11 +153,19 @@ LocationData.__new__.__defaults__ = (None,) * len(LocationData._fields)
AvatarMetaData = namedtuple('AvatarMetaData', 'bytes height width id type url')
AvatarMetaData.__new__.__defaults__ = (None,) * len(AvatarMetaData._fields)
AvatarData = namedtuple('AvatarData', 'jid sha data')
AvatarData.__new__.__defaults__ = (None,) * len(AvatarData._fields)
class AvatarData:
jid: JID
sha: Optional[str]
data: bytes
BookmarkData = namedtuple('BookmarkData', 'jid name nick autojoin password')
BookmarkData.__new__.__defaults__ = (None, None, None, None)
class BookmarkData:
jid: JID
name: Optional[str] = None
nick: Optional[str] = None
autojoin: bool = False
password: Optional[str] = None
BlockingListResult = namedtuple('BlockingListResult', 'blocking_list')
......@@ -113,26 +178,46 @@ OMEMOMessage = namedtuple('OMEMOMessage', 'sid iv keys payload')
AnnotationNote = namedtuple('AnnotationNote', 'jid data cdate mdate')
AnnotationNote.__new__.__defaults__ = (None, None)
EMEData = namedtuple('EMEData', 'name namespace')
class EMEData:
name: Optional[str]
namespace: str
MuclumbusResult = namedtuple('MuclumbusResult', 'first last max end items')
MuclumbusItem = namedtuple('MuclumbusItem', 'jid name nusers description language is_open anonymity_mode')
SoftwareVersionResult = namedtuple('SoftwareVersionResult', 'name version os')
AdHocCommandNote = namedtuple('AdHocCommandNote', 'text type')
IBBData = namedtuple('IBBData', 'block_size sid seq type data')
IBBData.__new__.__defaults__ = (None, None, None, None, None)
class SoftwareVersionResult:
name: str
version: str
os: Optional[str]
class AdHocCommandNote:
text: Optional[str]
type: AdHocNoteType = AdHocNoteType.INFO
class IBBData:
block_size: Optional[int] = None
sid: str
seq: Optional[int] = None
type: Optional[str] = None
data: Optional[bytes] = None
DiscoItems = namedtuple('DiscoItems', 'jid node items')
DiscoItem = namedtuple('DiscoItem', 'jid name node')
DiscoItem.__new__.__defaults__ = (None, None)
OOBData = namedtuple('OOBData', 'url desc')
class OOBData:
url: str
desc: Optional[str]
CorrectionData = namedtuple('CorrectionData', 'id')
class CorrectionData:
id: str
DisplayMarking = namedtuple('DisplayMarking', 'label fgcolor bgcolor')
SecurityLabel = namedtuple('SecurityLabel', 'displaymarking')
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