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: object

FileHandler is responsible for finding all the .py files within the input_path. example usage:

dir_files = FileHandler("./my_module").start()

By default, all the test files 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_path where they mach the pattern

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 path collect all valid .py files based on the exclude_patterns

Returns:

a dictionary for valid files within each directory.