14 lines
504 B
Python
14 lines
504 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from app.mailer.domain.campaign import MailAttachmentConfig
|
|
|
|
|
|
def match_files(base_path: Path, config: MailAttachmentConfig) -> list[Path]:
|
|
directory = base_path / config.base_dir
|
|
if not directory.exists():
|
|
return []
|
|
iterator = directory.rglob(config.file_filter) if config.include_subdirs else directory.glob(config.file_filter)
|
|
return sorted(path for path in iterator if path.is_file() and path.stat().st_size >= 0)
|