Per default use only files with .msg suffix ignoring other files.

This commit is contained in:
Oleksandr Kozachuk
2023-10-19 16:02:40 +02:00
parent 9b0951cb3f
commit 9a493b57da
+2 -2
View File
@@ -52,12 +52,12 @@ def read_dir(dir_path: Path,
Parameters: Parameters:
* 'dir_path': source directory * 'dir_path': source directory
* 'glob': if specified, files will be filtered using 'path.glob()', * 'glob': if specified, files will be filtered using 'path.glob()',
otherwise it uses 'path.iterdir()'. otherwise it uses '*{msg_suffix}'.
* 'mfilter': use with 'Message.from_file()' to filter messages * 'mfilter': use with 'Message.from_file()' to filter messages
when reading them. when reading them.
""" """
messages: list[Message] = [] messages: list[Message] = []
file_iter = dir_path.glob(glob) if glob else dir_path.iterdir() file_iter = dir_path.glob(glob) if glob else dir_path.glob(f'*{msg_suffix}')
for file_path in sorted(file_iter): for file_path in sorted(file_iter):
if (file_path.is_file() if (file_path.is_file()
and file_path.name not in ignored_files # noqa: W503 and file_path.name not in ignored_files # noqa: W503