class Hash(xso.XSO): """ Represent a single hash digest. .. attribute:: algo The hash algorithm used. The name is as specified in :xep:`300`. .. attribute:: digest The digest as :class:`bytes`. """ TAG = namespaces.xep0300_hashes2, "hash" algo = xso.Attr("algo", ) digest = xso.Text(type_=xso.Base64Binary()) def __init__(self, algo, digest): super().__init__() self.algo = algo self.digest = digest def get_impl(self): """ Return a new :mod:`hashlib` hash for the :attr:`algo` set on this object. See :func:`hash_from_algo` for details and exceptions. """ return hash_from_algo(self.algo)
class DeepLeaf(xso.XSO): TAG = ("uri:test", "leaf") data = xso.Text() def generate(self, rng, depth): self.data = "foo" * (2 * rng.randint(1, 10))
class ShallowRoot(xso.XSO): TAG = ("uri:test", "shallow") attr = xso.Attr("a") data = xso.Text() def __init__(self, scale=1): super().__init__() self.attr = "foobar" * (2 * scale) self.data = "fnord" * (10 * scale)
class Header(xso.XSO): TAG = (namespaces.xep0131_shim, "header") name = xso.Attr("name", ) value = xso.Text() def __init__(self, name, value): super().__init__() self.name = name self.value = value
class Data(xso.XSO): TAG = (namespaces.xep0047, "data") seq = xso.Attr("seq", type_=xso.Integer()) sid = xso.Attr("sid", type_=xso.String()) content = xso.Text(type_=xso.Base64Binary()) def __init__(self, sid, seq, content): self.seq = seq self.sid = sid self.content = content
class DirectInvite(xso.XSO): TAG = namespaces.xep0249_conference, "x" # JEP-0045 v1.19 ยง6.7 allowed a mediated(!) invitation to contain a # (what is now) DirectInvite payload where the reason is included as # text (and not as attribute). # # Some servers still emit this for compatibility. We ignore that. _ = xso.Text(default=None) jid = xso.Attr( "jid", type_=xso.JID(), ) reason = xso.Attr( "reason", default=None, ) password = xso.Attr( "password", default=None, ) continue_ = xso.Attr( "continue", type_=xso.Bool(), default=False, ) thread = xso.Attr( "thread", default=None, ) def __init__(self, jid, *, reason=None, password=None, continue_=False, thread=None): super().__init__() self.jid = jid self.reason = reason self.password = password self.continue_ = continue_ self.thread = thread
class JSONContainer(xso.XSO): """ XSO which represents the JSON container specified in :xep:`335`. This is a full XSO and not an attribute descriptor. It is registered as pubsub payload by default. """ TAG = (namespaces.xep0335_json, "json") json_data = xso.Text(type_=xso.JSON(), ) def __init__(self, json_data=None): super().__init__() self.json_data = json_data
class Data(xso.XSO): """ A data node, as used to publish and receive the avatar image data as image/png. .. attribute:: data The binary image data. """ TAG = (namespaces.xep0084_data, "data") data = xso.Text(type_=xso.Base64Binary()) def __init__(self, image_data): self.data = image_data
class Group(xso.XSO): """ A group declaration for a contact in a roster. .. attribute:: name The name of the group. """ TAG = (namespaces.rfc6121_roster, "group") name = xso.Text(default=None) def __init__(self, *, name=None): super().__init__() self.name = name
class Note(xso.XSO): TAG = (namespaces.xep0050_commands, "note") body = xso.Text( default=None, ) type_ = xso.Attr( "type", type_=xso.EnumType( NoteType, ), default=NoteType.INFO, ) def __init__(self, type_, body): super().__init__() self.type_ = type_ self.body = body
class Delay(xso.XSO): """ A marker indicating delayed delivery of a stanza. .. attribute:: from_ The address as :class:`aioxmpp.JID` of the entity where the stanza was delayed. May be :data:`None`. .. attribute:: stamp The timestamp (as :class:`datetime.datetime`) at which the stanza was originally sent or intended to be sent. .. attribute:: reason The reason for which the stanza was delayed or :data:`None`. .. warning:: Please take the security considerations of :xep:`203` into account. """ TAG = namespaces.xep0203_delay, "delay" from_ = xso.Attr( "from", type_=xso.JID(), default=None, ) stamp = xso.Attr( "stamp", type_=xso.DateTime(), ) reason = xso.Text(default=None)
class Instructions(xso.XSO): TAG = (namespaces.xep0004_data, "instructions") value = xso.Text(default="")
class Value(xso.XSO): TAG = (namespaces.xep0004_data, "value") value = xso.Text(default="")
class ExamplePayload(xso.XSO): TAG = ("urn:example:payload", "payload") data = xso.Text()
class Example(xso.XSO): TAG = ("urn:example:registered", "example") data = xso.Text(type_=xso.String()) def __init__(self, text=""): self.data = text
class _RangeLimitBase(xso.XSO): value = xso.Text(default=None) def __init__(self, value=None): super().__init__() self.value = value