core.utils.fetchers.BaseFetcher module¶
Module with the BaseFetcher class template.
- class core.utils.fetchers.BaseFetcher.BaseFetcher(account)[source]¶
Bases:
ABCTemplate class for the mailfetcher classes.
Provides arg-checking for methods.
- Parameters:
account (Account)
- PROTOCOL = ''¶
Name of the used protocol, should be one of
MailFetchingProtocols.
- AVAILABLE_FETCHING_CRITERIA: tuple[str, ...] = ('',)¶
Tuple of all criteria available for fetching. Should refer to
MailFetchingCriteria. Must be immutable!
- DEFAULT_FETCHING_CRITERION = <core.utils.FetchingCriterion.FetchingCriterion object>¶
Default criterion to use for fetching emails with the fetcher class.
- abstractmethod __init__(account)[source]¶
Constructor basis, sets up the instance logger.
- Parameters:
account (
Account) – The model of the account to fetch from.- Return type:
None
- abstractmethod 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:
- abstractmethod 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:
- abstractmethod 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:
- __str__()[source]¶
Returns a string representation of the
BaseFetcherinstances.- Return type:
- Returns:
The string representation of the fetcher instance.