This document is for Kombu's development version, which can be significantly different from previous releases. Get the stable docs here: 5.3.

# Pattern matching registry - `kombu.matcher`

Pattern matching registry.

exception kombu.matcher.MatcherNotInstalled

  Matcher not installed/found.

class kombu.matcher.MatcherRegistry

  Pattern matching function registry.

  exception MatcherNotInstalled

    Matcher not installed/found.

  match(data: bytes, pattern: bytes, matcher: str | None = None, matcher_kwargs: dict[str, str] | None = None) → bool

    Call the matcher.

  matcher_pattern_first = ['pcre']
  register(name: str, matcher: Callable[[str, str], bool]) → None

    Add matcher by name to the registry.

  unregister(name: str) → None

    Remove matcher by name from the registry.

kombu.matcher.match(data: bytes, pattern: bytes, matcher: str | None = None, matcher_kwargs: dict[str, str] | None = None) → bool
  register(name, matcher):
  Register a new matching method.
    Parameters:

      - name – A convenient name for the matching method.

      - matcher – A method that will be passed data and pattern.

kombu.matcher.register(name: str, matcher: Callable[[str, str], bool]) → None
  unregister(name):
  Unregister registered matching method.
    Parameters:

      name – Registered matching method name.

kombu.matcher.register_glob() → None

  Register glob into default registry.

kombu.matcher.register_pcre() → None

  Register pcre into default registry.

kombu.matcher.registry = <kombu.matcher.MatcherRegistry object>
  match(data, pattern, matcher=default_matcher,
  matcher_kwargs=None):

  Match data by pattern using matcher.

  Parameters:

    - data – The data that should be matched. Must be string.

    - pattern – The pattern that should be applied. Must be string.

  Keyword Arguments:

    - matcher –

      An optional string representing the matching method (for example, glob or pcre).

      If `None` (default), then glob will be used.

    - matcher_kwargs – Additional keyword arguments that will be passed to the specified matcher.

  Returns:

    `True` if data matches pattern, `False` otherwise.

  Raises:

    MatcherNotInstalled – If the matching method requested is not available.

kombu.matcher.unregister(name: str) → None

  Remove matcher by name from the registry.