core.utils.fetchers.JMAPFetcher module¶
Module with the JMAPFetcher class.
- class core.utils.fetchers.JMAPFetcher.JMAPFetcher(account)[source]¶
Bases:
BaseFetcherMaintains a connection to the JMAP server and fetches data using
jmapc.Opens a connection to the JMAP server on construction and is preferably used in a ‘with’ environment. Allows fetching of mails and mailboxes from an account on an JMAP host.
- Parameters:
account (Account)
- PROTOCOL = 'JMAP'¶
Name of the used protocol, refers to
MailFetchingProtocols.JMAP.
- AVAILABLE_FETCHING_CRITERIA: tuple[str, ...] = (EmailFetchingCriterionChoices.ALL, EmailFetchingCriterionChoices.SEEN, EmailFetchingCriterionChoices.UNSEEN, EmailFetchingCriterionChoices.DRAFT, EmailFetchingCriterionChoices.UNDRAFT, EmailFetchingCriterionChoices.ANSWERED, EmailFetchingCriterionChoices.UNANSWERED, EmailFetchingCriterionChoices.DAILY, EmailFetchingCriterionChoices.WEEKLY, EmailFetchingCriterionChoices.MONTHLY, EmailFetchingCriterionChoices.ANNUALLY, EmailFetchingCriterionChoices.BODY, EmailFetchingCriterionChoices.FROM, EmailFetchingCriterionChoices.SENTSINCE, EmailFetchingCriterionChoices.LARGER, EmailFetchingCriterionChoices.SMALLER)¶
Tuple of all criteria available for fetching. Refers to
MailFetchingCriteria. Must be immutable!
- __init__(account)[source]¶
Constructor basis, sets up the instance logger.
- Parameters:
account (
Account) – The model of the account to fetch from.- Return type:
None
- test(mailbox=None)[source]¶
Tests the connection to the mailaccount and, if given, the mailbox.
- Parameters:
mailbox (
Mailbox|None) – The mailbox to be tested. Default is None.- Raises:
ValueError – If the mailbox argument does not belong to
self.account.- Return type:
- fetch_emails(mailbox, criterion=<core.utils.FetchingCriterion.FetchingCriterion object>)[source]¶
Fetches emails based on a criterion from the server.
- Parameters:
mailbox (
Mailbox) – The model of the mailbox to fetch data from.criterion (
FetchingCriterion) – Formatted criterion to filter mails by. Defaults tocore.constants.EmailFetchingCriterionChoices.ALL.
- Yields:
Mails in the mailbox matching the criterion as
bytes.- Raises:
ValueError – If the
fetching_criterionis not available for this fetcher.- Return type:
- restore(email)[source]¶
Restores an email to a mailbox.
- Parameters:
email (
Email) – The email to restore.- Raises:
ValueError – If the emails mailbox is not in this fetchers account.
FileNotFoundError – If the emails file_path is not set.
- Return type: