MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / match

Method match

tools/python-3.11.9-amd64/Lib/pathlib.py:804–827  ·  view source on GitHub ↗

Return True if this path matches the given pattern.

(self, path_pattern)

Source from the content-addressed store, hash-verified

802 return self._flavour.is_reserved(self._parts)
803
804 def match(self, path_pattern):
805 """
806 Return True if this path matches the given pattern.
807 """
808 cf = self._flavour.casefold
809 path_pattern = cf(path_pattern)
810 drv, root, pat_parts = self._flavour.parse_parts((path_pattern,))
811 if not pat_parts:
812 raise ValueError("empty pattern")
813 if drv and drv != cf(self._drv):
814 return False
815 if root and root != cf(self._root):
816 return False
817 parts = self._cparts
818 if drv or root:
819 if len(pat_parts) != len(parts):
820 return False
821 pat_parts = pat_parts[1:]
822 elif len(pat_parts) > len(parts):
823 return False
824 for part, pat in zip(reversed(parts), reversed(pat_parts)):
825 if not fnmatch.fnmatchcase(part, pat):
826 return False
827 return True
828
829# Can't subclass os.PathLike from PurePath and keep the constructor
830# optimizations in PurePath._parse_args().

Callers 15

_matchMethod · 0.45
Internaldate2tupleFunction · 0.45
ParseFlagsFunction · 0.45
imaplib.pyFile · 0.45
_strptimeFunction · 0.45
attr_matchesMethod · 0.45
formatFunction · 0.45
resolve_nameFunction · 0.45
remove_numberMethod · 0.45
findsourceFunction · 0.45
apopMethod · 0.45

Calls 1

parse_partsMethod · 0.80

Tested by 3

_parse_exampleMethod · 0.36
_find_linenoMethod · 0.36