id.py 798 Bytes
Newer Older
Nathan Fritz's avatar
Nathan Fritz committed
1

2 3 4 5 6
# slixmpp.xmlstream.matcher.id
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Part of Slixmpp: The Slick XMPP Library
# :copyright: (c) 2011 Nathanael C. Fritz
# :license: MIT, see LICENSE for more details
louiz’'s avatar
louiz’ committed
7
from slixmpp.xmlstream.matcher.base import MatcherBase
mathieui's avatar
mathieui committed
8
from slixmpp.xmlstream.stanzabase import StanzaBase
9 10 11 12 13 14 15 16


class MatcherId(MatcherBase):

    """
    The ID matcher selects stanzas that have the same stanza 'id'
    interface value as the desired ID.
    """
mathieui's avatar
mathieui committed
17
    _criteria: str
18

mathieui's avatar
mathieui committed
19
    def match(self, xml: StanzaBase) -> bool:
20 21
        """Compare the given stanza's ``'id'`` attribute to the stored
        ``id`` value.
22

mathieui's avatar
mathieui committed
23
        :param xml: The :class:`~slixmpp.xmlstream.stanzabase.StanzaBase`
24
                    stanza to compare against.
25
        """
mathieui's avatar
mathieui committed
26
        return bool(xml['id'] == self._criteria)