monty.fnmatch module — monty 2021.8.17 documentation

# monty.fnmatch module

This module provides support for Unix shell-style wildcards

class WildCard(wildcard, sep='|')

  Bases: `object`

  This object provides an easy-to-use interface for filename matching with shell patterns (fnmatch).

      >>> w = WildCard("*.nc|*.pdf")
      >>> w.filter(["foo.nc", "bar.pdf", "hello.txt"])
      ['foo.nc', 'bar.pdf']

      >>> w.filter("foo.nc")
      ['foo.nc']

  Initializes a WildCard.

  Parameters

    - wildcard (str) – String of tokens separated by sep. Each token represents a pattern.

    - sep (str) – Separator for shell patterns.

  filter(names)

    Returns a list with the names matching the pattern.

  match(name)

    Returns True if name matches one of the patterns.