File Filter

File Filtering for Copcon.

This module provides functionality to filter files and directories based on ignore patterns specified in .copconignore files and additional user-defined patterns. It also supports a .copcontarget file to target specific directories and files.

class copcon.core.file_filter.FileFilter(additional_dirs=None, additional_files=None, user_ignore_path=None, user_target_path=None)

Bases: object

Filters files and directories based on ignore and target patterns.

Combines internal, user-specified ignore patterns, and target patterns to determine whether a file or directory should be excluded from processing.

has_user_defined_ignore()

Check if a user-defined .copconignore was loaded.

Returns:

True if a user-defined .copconignore was loaded, False otherwise.

Return type:

bool

should_ignore(path)

Determine whether a given file or directory should be ignored.

Parameters:

path (Path) – The file or directory path to check.

Returns:

True if the path should be ignored, False otherwise.

Return type:

bool