src.file_handler module¶
FileHandler implementation glob patterns
**: Recursively matches zero or more directories
that fall under the current directory.
* : On Unix, will match everything except slashes.
On Windows, it will avoid matching backslashes as well as slashes.
- class src.file_handler.FileHandler(input_path: Path, additional_exclude_patterns: list[str] | None = None)¶
Bases:
objectFileHandler is responsible for finding all the
.pyfiles within theinput_path. example usage:dir_files = FileHandler("./my_module").start()
By default, all the
testfiles and any__init__files are excluded.- Parameters:
input_path – Should be a valid file/directory path.
additional_exclude_patterns – Any optional additional glob patterns.
- collect_with_pattern(pattern: str) Generator[Path, None, None]¶
Collects all python files within the
input_pathwhere they mach thepattern- Parameters:
pattern – str containing glob patters
- Returns:
A Generator of file paths.
- property exclude_patterns: list[str]¶
Current glob exclude patterns
- property input_path: Path¶
Current input path
- start() dict[str, list[Path]]¶
For the given
input pathcollect all valid.pyfiles based on theexclude_patterns- Returns:
a dictionary for valid files within each directory.