Spaces:
Sleeping
Sleeping
File size: 859 Bytes
16bbb61 60532a1 16bbb61 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
from pathlib import Path
from typing import Generator
from knowlang.configs.config import AppConfig
from knowlang.parser.base.provider import CodeProvider
import os
class FilesystemProvider(CodeProvider):
"""Provides code files from a filesystem directory"""
def __init__(self, directory: Path, config: AppConfig):
self.directory = directory
self.config = config
def get_files(self) -> Generator[Path, None, None]:
for dirpath, _, filenames in os.walk(self.directory):
dir_path = Path(dirpath)
if not self.config.parser.path_patterns.should_process_path(dir_path):
continue
for filename in filenames:
file_path = dir_path / filename
if self.config.parser.path_patterns.should_process_path(file_path):
yield file_path |