message: added function 'rm_file()' and test

This commit is contained in:
2023-09-27 08:14:56 +02:00
parent 01860ace2c
commit 140dbed809
2 changed files with 26 additions and 0 deletions
+7
View File
@@ -517,6 +517,13 @@ class Message():
yaml.dump(data, temp_fd, sort_keys=False)
shutil.move(temp_file_path, file_path)
def rm_file(self) -> None:
"""
Delete the message file. Ignore empty file_path and not existing files.
"""
if self.file_path is not None:
self.file_path.unlink(missing_ok=True)
def filter_tags(self, prefix: Optional[str] = None, contain: Optional[str] = None) -> set[Tag]:
"""
Filter tags based on their prefix (i. e. the tag starts with a given string)