def fnmatch(self, pattern, normcase=None):
"""Return ``True`` if :attr:`name` matches the given ``pattern``.
.. seealso:: :func:`fnmatch.fnmatch`
Args:
pattern (str): A filename pattern with wildcards,
for example ``'*.py'``. If the pattern contains a `normcase`
attribute, it is applied to the name and path prior to comparison.
normcase (func, optional): A function used to normalize the pattern and
filename before matching. Defaults to :meth:`self.module`, which defaults
to :meth:`os.path.normcase`.
"""
default_normcase = getattr(pattern, 'normcase', self.path_module.normcase)
normcase = normcase or default_normcase
name = normcase(self.name)
pattern = normcase(pattern)
return fnmatch.fnmatchcase(name, pattern)
评论列表
文章目录