How to use the aioxmpp.xso function in aioxmpp

To help you get started, we’ve selected a few aioxmpp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github horazont / aioxmpp / tests / disco / test_xso.py View on Github external
def test_var_attr(self):
        self.assertIsInstance(
            disco_xso.Feature.var,
            xso.Attr
        )
        self.assertEqual(
            (None, "var"),
            disco_xso.Feature.var.tag
        )
        self.assertIs(
            xso.NO_DEFAULT,
            disco_xso.Feature.var.default
        )
github horazont / aioxmpp / tests / shim / test_xso.py View on Github external
def test_headers_attribute_on_Presence(self):
        self.assertIsInstance(
            aioxmpp.stanza.Presence.xep0131_headers,
            xso.Child,
        )
        self.assertSetEqual(
            aioxmpp.stanza.Presence.xep0131_headers._classes,
            {
                shim_xso.Headers,
            }
github horazont / aioxmpp / tests / rsm / test_xso.py View on Github external
def test_is_xso(self):
        self.assertTrue(issubclass(
            rsm_xso._RangeLimitBase,
            xso.XSO,
        ))
github horazont / aioxmpp / tests / test_nonza.py View on Github external
def test_text(self):
        self.assertIsInstance(
            nonza.SASLFailure.text,
            xso.ChildText
        )
        self.assertEqual(
            nonza.SASLFailure.text.tag,
            (namespaces.sasl, "text")
        )
        self.assertEqual(
            nonza.SASLFailure.text.attr_policy,
            xso.UnknownAttrPolicy.DROP
        )
        self.assertIs(
            nonza.SASLFailure.text.default,
            None
        )
        self.assertIs(
            nonza.SASLFailure.text.declare_prefix,
            None
github horazont / aioxmpp / tests / test_rfc3921.py View on Github external
def test_is_xso(self):
        self.assertTrue(issubclass(
            rfc3921.SessionFeature,
            xso.XSO
        ))
github horazont / aioxmpp / aioxmpp / rfc3921.py View on Github external
UNKNOWN_ATTR_POLICY = xso.UnknownAttrPolicy.DROP

    TAG = (namespaces.rfc3921_session, "session")


@nonza.StreamFeatures.as_feature_class
class SessionFeature(xso.XSO):
    """
    Stream feature which the server uses to announce that it supports legacy
    XMPP sessions.

    .. versionadded:: 0.4
    """

    UNKNOWN_CHILD_POLICY = xso.UnknownChildPolicy.DROP
    UNKNOWN_ATTR_POLICY = xso.UnknownAttrPolicy.DROP

    TAG = (namespaces.rfc3921_session, "session")

    optional = xso.ChildFlag(
        (namespaces.rfc3921_session, "optional")
    )
github horazont / aioxmpp / aioxmpp / stanza.py View on Github external
parent thread identifier.

    .. attribute:: identifier

       Identifier of the thread

    .. attribute:: parent

       :data:`None` or the identifier of the parent thread.

    """
    TAG = (namespaces.client, "thread")

    identifier = xso.Text(
        validator=xso.Nmtoken(),
        validate=xso.ValidateMode.FROM_CODE)
    parent = xso.Attr(
        tag="parent",
        validator=xso.Nmtoken(),
        validate=xso.ValidateMode.FROM_CODE,
        default=None
    )


class Body(xso.AbstractTextChild):
    """
    The textual body of a :class:`Message` stanza.

    While it might seem intuitive to refer to the body using a
    :class:`~.xso.ChildText` descriptor, the fact that there might be multiple
    texts for different languages justifies the use of a separate class.
github horazont / aioxmpp / aioxmpp / forms / xso.py View on Github external
.. attribute:: reported

       If the :class:`Data` is a table, this is a :class:`Reported` object
       representing the table header.

       This only makes sense on :attr:`.DataType.RESULT` typed objects.

    .. automethod:: get_form_type
    """

    TAG = (namespaces.xep0004_data, "x")

    type_ = xso.Attr(
        "type",
        type_=xso.EnumCDataType(DataType)
    )

    title = xso.ChildText(
        (namespaces.xep0004_data, "title"),
        default=None,
    )

    instructions = xso.ChildValueList(
        type_=InstructionsElement()
    )

    items = xso.ChildList([Item])

    reported = xso.Child([Reported], required=False)

    def __init__(self, type_):
github horazont / muchopper / muchopper / bot / xso.py View on Github external
SearchResultItem,
    ])

    rsm = aioxmpp.xso.Child([
        aioxmpp.rsm.xso.ResultSetMetadata,
    ])


@aioxmpp.pubsub.xso.as_payload_class
class SyncItemMUC(aioxmpp.xso.XSO):
    TAG = (
        StateTransferV1_0Namespaces.MUCS.value,
        "muc"
    )

    address = aioxmpp.xso.Attr(
        "address",
        type_=aioxmpp.xso.JID(),
    )

    name = aioxmpp.xso.ChildText(
        (StateTransferV1_0Namespaces.MUCS.value, "name"),
        default=None,
    )

    description = aioxmpp.xso.ChildText(
        (StateTransferV1_0Namespaces.MUCS.value, "description"),
        default=None,
    )

    language = aioxmpp.xso.ChildText(
        (StateTransferV1_0Namespaces.MUCS.value, "language"),
github horazont / aioxmpp / aioxmpp / stanza.py View on Github external
type_=xso.EnumCDataType(
            structs.PresenceShow,
            allow_coerce=True,
            deprecate_coerce=True,
            allow_unknown=False,
            accept_unknown=False,
        ),
        default=structs.PresenceShow.NONE,
        erroneous_as_absent=True,
    )

    status = xso.ChildTextMap(Status)

    priority = xso.ChildText(
        tag=(namespaces.client, "priority"),
        type_=xso.Integer(),
        default=0
    )

    ext = xso.ChildMap([])
    unhandled_children = xso.Collector()

    def __init__(self, *,
                 type_=structs.PresenceType.AVAILABLE,
                 show=structs.PresenceShow.NONE, **kwargs):
        super().__init__(**kwargs)
        self.type_ = type_
        self.show = show

    def __repr__(self):
        return "".format(
            _safe_format_attr(self, "from_"),