monty.fnmatch module

This module provides support for Unix shell-style wildcards

class WildCard(wildcard, sep='|')[source]

Bases: object

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

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

Initializes a WildCard.

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

  • sep (str) – Separator for shell patterns.


Returns a list with the names matching the pattern.


Returns True if name matches one of the patterns.