base.py 795 Bytes
Newer Older
1 2 3 4 5
# slixmpp.xmlstream.matcher.base
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Part of Slixmpp: The Slick XMPP Library
# :copyright: (c) 2011 Nathanael C. Fritz
# :license: MIT, see LICENSE for more details
6

mathieui's avatar
mathieui committed
7 8 9 10
from typing import Any
from slixmpp.xmlstream.stanzabase import StanzaBase


Nathan Fritz's avatar
Nathan Fritz committed
11 12
class MatcherBase(object):

13 14 15 16
    """
    Base class for stanza matchers. Stanza matchers are used to pick
    stanzas out of the XML stream and pass them to the appropriate
    stream handlers.
17 18

    :param criteria: Object to compare some aspect of a stanza against.
19 20
    """

mathieui's avatar
mathieui committed
21
    def __init__(self, criteria: Any):
22 23
        self._criteria = criteria

mathieui's avatar
mathieui committed
24
    def match(self, xml: StanzaBase) -> bool:
25
        """Check if a stanza matches the stored criteria.
26 27 28 29

        Meant to be overridden.
        """
        return False