Add file deletion *NEEDS TESTS*
This commit is contained in:
parent
e2698281c4
commit
5fa7e7bde9
@ -1,10 +1,17 @@
|
||||
"""Module containing functionality to interact with the filesystem"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from maildirclean.maildir import MailDir, TopSender
|
||||
|
||||
|
||||
def delete_files(file_list: list[str | Path]):
|
||||
def delete_all_from_selected_email(selected_senders: list[TopSender], maildir: MailDir):
|
||||
for sender in selected_senders:
|
||||
delete_files(maildir.get_paths_for_email(sender.email))
|
||||
maildir.remove_email(sender.email)
|
||||
|
||||
|
||||
def delete_files(file_list: list[str]):
|
||||
"""Delete all files in the provided file list
|
||||
|
||||
Args:
|
||||
|
@ -119,3 +119,9 @@ class MailDir:
|
||||
]
|
||||
|
||||
return senders
|
||||
|
||||
def get_paths_for_email(self, email: str) -> list[str]:
|
||||
return self._df.loc[self._df == email, "path"].to_list()
|
||||
|
||||
def remove_email(self, email: str):
|
||||
self._df.drop(self._df[self._df["email"] == email].index, inplace=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user