Chore: switch from os.path to pathlib.Path (#9933)

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
Sebastian Steinbeißer
2025-06-18 19:16:59 +02:00
committed by GitHub
parent cc5ba71f06
commit 07882b918b
6 changed files with 104 additions and 106 deletions

View File

@@ -1,7 +1,6 @@
import datetime
import itertools
import logging
import os
import ssl
import tempfile
import traceback
@@ -484,7 +483,7 @@ class MailAccountHandler(LoggingMixin):
return message.subject
elif rule.assign_title_from == MailRule.TitleSource.FROM_FILENAME:
return os.path.splitext(os.path.basename(att.filename))[0]
return Path(att.filename).stem
elif rule.assign_title_from == MailRule.TitleSource.NONE:
return None
@@ -908,7 +907,7 @@ class MailAccountHandler(LoggingMixin):
dir=settings.SCRATCH_DIR,
suffix=".eml",
)
with open(temp_filename, "wb") as f:
with Path(temp_filename).open("wb") as f:
# Move "From"-header to beginning of file
# TODO: This ugly workaround is needed because the parser is
# chosen only by the mime_type detected via magic