imap_storage.storage package¶
Subpackages¶
Submodules¶
imap_storage.storage.directory module¶
Directory class This represents a physical directory at storage level (imap)
-
class
imap_storage.storage.directory.
Directory
(storage, folder)[source]¶ Bases:
object
Directory class
-
add_file_email
(file)[source]¶ Create new Email with one file
Parameters: file (File) – object to append as file to the directory Returns: new created file Email Return type: Email
-
app_name
¶ the name of the application of this directory
Returns: Return type: str
path of this directory in breadcrumb format
Returns: [self.parent.parent.parent, self.parent.parent, self.parent] Return type: list
-
childs
¶ childs of this directory
Returns: of directories [Directory, …] Return type: list
-
delete
()[source]¶ Delete this storage
Warning
Also deletes its subdirectories recursively
Returns: True if success Return type: bool
-
delete_email
(email_uid_or_obj)[source]¶ delete email within this directory
Parameters: email_uid_or_obj (Email, int, str) – email to delete Returns: True if success Return type: bool
-
email_by_uid
(uid)[source]¶ get email by uid
Parameters: uid (int) – uid you want to have the email object Returns: if email with uid exists in this directory or None Return type: Email
-
emails
¶ cannot be dynamic because of self.fetch methods
-
fetch_body
(email)[source]¶ fetch email body
Parameters: email (Email) – fetch body of this email Returns: body of email Return type: str
-
fetch_head
(email)[source]¶ fetch email head
Parameters: email (Email) – fetch head of this email Returns: head of email Return type: str
-
fetch_subjects
(email=None)[source]¶ fetch subjects
Parameters: email (Email, optional) – fetch only from this email Returns: {uid: subject} Return type: dict
-
file_by_name
(name)[source]¶ get file by name
Parameters: name (str) – name of the file to get Returns: first file with name Return type: File
-
files
¶ List files of all emails inside this directory
Returns: of files Return type: list
-
item_name
¶ this is the name of the item
Returns: str
-
new_email
(item_name, from_addr=None, from_displ=None)[source]¶ needs to be runned if its a ne Email with no uid
-
uids
¶ keep this uptodate because self.emails compares to it
-
url
¶ makes the Django life easier
Returns: path as url Return type: str
-
imap_storage.storage.storage module¶
Factory for Storage This is the layer between bare Imap and the directories that hold the data
-
class
imap_storage.storage.storage.
Storage
(imap)[source]¶ Bases:
object
Storage is the view of the IMAP directory
-
clean_folder_path
(folder_name)[source]¶ Parameters: folder_name (str) – folder name to clean Returns: cleaned folder name Return type: str
-
delete_directory
(path)[source]¶ Delete directory and its subdirectories
Parameters: path (str) – directory path to delete Returns: of paths(str) that have been deleted at imap Return type: list
-
directories
¶ Lists of all Directory objects at this storage
Returns: Containing Directory objects Return type: list
-
directory_by_path
(path)[source]¶ Parameters: path (str) – find directory with that path Returns: with the given path Return type: Directory
-
get_bodies
(uids)[source]¶ fetch the body of one or multiple messages
Parameters: uids – which message bodies should get fetched. can be one of type(list, str, float, int) Returns: with bodies of uids {int(uid): str(body)} Return type: dict
-
get_file_payloads
(uids)[source]¶ fetch the payload of one or multiple messages :param uids: which message payloads should get fetched.
can be one of type(list, str, float, int)Returns: with payloads of uids {int(uid): payloads of uid} Return type: dict
-
get_heads
(uids)[source]¶ fetch the head of one or multiple messages
Parameters: uids – which message heads should get fetched. can be one of type(list, str, float, int) Returns: with heads of uids {int(uid): str(head)} Return type: dict
-
get_subjects
(folder=None)[source]¶ Fetch subjects
Parameters: folder (str, optional) – select which folder you want to fetch subjects of. It will be created and selected if needed. Returns: of subjects and uids {subject: [uid, uid]} Return type: dict
-