feat: use .gitignore

This commit is contained in:
2026-08-06 01:20:58 +03:00
parent d062447e6d
commit 9d15380443
13 changed files with 183 additions and 130 deletions
+28
View File
@@ -0,0 +1,28 @@
from pathlib import Path
from typing import Iterable
from pathspec import PathSpec
from .detector import EntryDetector
from .entry import Entry
class EntryResolver:
def __init__(self, detector: EntryDetector, ignore: PathSpec, max_depth: int = 4):
self._detector = detector
self._ignore = ignore
self._max_depth = max_depth
def _resolve(self, basepath: Path, depth: int = 0) -> Iterable[Entry]:
if basepath.is_dir():
if self._ignore.match_file(basepath):
return
entry = self._detector.detect_entry(basepath)
if entry:
yield entry
if depth < self._max_depth and basepath.is_dir():
for path in basepath.iterdir():
yield from self._resolve(path, depth + 1)
def resolve(self, basepath: Path) -> Iterable[Entry]:
return self._resolve(basepath)