many.py 999 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. """
  2. SleekXMPP: The Sleek XMPP Library
  3. Copyright (C) 2010 Nathanael C. Fritz
  4. This file is part of SleekXMPP.
  5. See the file LICENSE for copying permission.
  6. """
  7. from sleekxmpp.xmlstream.matcher.base import MatcherBase
  8. class MatchMany(MatcherBase):
  9. """
  10. The MatchMany matcher may compare a stanza against multiple
  11. criteria. It is essentially an OR relation combining multiple
  12. matchers.
  13. Each of the criteria must implement a match() method.
  14. Methods:
  15. match -- Overrides MatcherBase.match.
  16. """
  17. def match(self, xml):
  18. """
  19. Match a stanza against multiple criteria. The match is successful
  20. if one of the criteria matches.
  21. Each of the criteria must implement a match() method.
  22. Overrides MatcherBase.match.
  23. Arguments:
  24. xml -- The stanza object to compare against.
  25. """
  26. for m in self._criteria:
  27. if m.match(xml):
  28. return True
  29. return False