MCPcopy Create free account
hub / github.com/ParzivalHack/PySpector / _is_path_excluded

Function _is_path_excluded

src/pyspector/cli.py:157–178  ·  view source on GitHub ↗

Return True if *file_path* matches any of the *patterns* (fnmatch-style). Patterns are matched against the path relative to *root*, against the absolute path, and against each individual path component. This lets bare names like ".venv" or "node_modules" prune whole subtrees regardless

(file_path: Path, root: Path, patterns: List[str])

Source from the content-addressed store, hash-verified

155 for pattern in skip_patterns:
156 if pattern in path_str.replace('\\', '/'):
157 return True
158 filename = file_path.name
159 if filename.startswith('test_') or filename.endswith('_test.py'):
160 if '/tests/' in path_str.replace('\\', '/') or '/test/' in path_str.replace('\\', '/'):
161 return True
162 return False
163
164
165def _is_path_excluded(file_path: Path, root: Path, patterns: List[str]) -> bool:
166 """Return True if *file_path* matches any of the *patterns* (fnmatch-style).
167
168 Patterns are matched against the path relative to *root*, against the
169 absolute path, and against each individual path component. This lets
170 bare names like ".venv" or "node_modules" prune whole subtrees regardless
171 of depth.
172 """
173 import fnmatch
174 try:
175 rel = file_path.relative_to(root)
176 except ValueError:
177 rel = file_path
178 rel_str = str(rel).replace("\\", "/")
179 abs_str = str(file_path).replace("\\", "/")
180 parts = set(rel.parts) | set(file_path.parts)
181 for pat in patterns:

Callers 1

get_python_file_astsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected