MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / _load_ignore_patterns

Function _load_ignore_patterns

core/context.py:20–38  ·  view source on GitHub ↗

Load and cache .codeyignore patterns for a given cwd.

(cwd: str)

Source from the content-addressed store, hash-verified

18_ignore_cache: dict = {}
19
20def _load_ignore_patterns(cwd: str) -> frozenset:
21 """Load and cache .codeyignore patterns for a given cwd."""
22 ignore_file = Path(cwd) / ".codeyignore"
23 mtime = ignore_file.stat().st_mtime if ignore_file.exists() else None
24 cached = _ignore_cache.get(cwd)
25 if cached and cached[0] == mtime:
26 return cached[1]
27 patterns = set(_DEFAULT_IGNORE)
28 if ignore_file.exists():
29 try:
30 for line in ignore_file.read_text().splitlines():
31 line = line.strip()
32 if line and not line.startswith("#"):
33 patterns.add(line)
34 except Exception:
35 pass
36 result = frozenset(patterns)
37 _ignore_cache[cwd] = (mtime, result)
38 return result
39
40def is_ignored(path):
41 """Check if a file should be ignored based on .codeyignore or defaults."""

Callers 1

is_ignoredFunction · 0.85

Calls 3

existsMethod · 0.80
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected