MCPcopy Index your code
hub / github.com/python/cpython / FileSuffixSet

Class FileSuffixSet

PC/layout/support/filesets.py:41–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40
41class FileSuffixSet:
42 def __init__(self, *patterns):
43 self._names = set()
44 self._prefixes = []
45 self._suffixes = []
46 for p in map(os.path.normcase, patterns):
47 if p.startswith("*."):
48 self._names.add(p[1:])
49 elif p.startswith("*"):
50 self._suffixes.append(p[1:])
51 elif p.endswith("*"):
52 self._prefixes.append(p[:-1])
53 elif p.startswith("."):
54 self._names.add(p)
55 else:
56 self._names.add("." + p)
57
58 def _make_name(self, f):
59 return os.path.normcase(f.suffix)
60
61 def __contains__(self, f):
62 bn = self._make_name(f)
63 return (
64 bn in self._names
65 or any(map(bn.startswith, self._prefixes))
66 or any(map(bn.endswith, self._suffixes))
67 )
68
69
70def _rglob(root, pattern, condition):

Callers 1

main.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…