core.utils.FetchingCriterion module

Module with the FetchingCriterion utility class.

class core.utils.FetchingCriterion.FetchingCriterion(criterion, argument='')[source]

Bases: object

Class encapsulating the fetching-criterion logic.

Parameters:
__init__(criterion, argument='')[source]

Constructor.

Parameters:
  • criterion (EmailFetchingCriterionChoices) – One of the class:core.constants.EmailFetchingCriterionChoices.

  • argument (str) – Argument for the criterion. Defaults to “”.

Return type:

None

__str__()[source]

The formatted criterion as a string.

Return type:

str

Returns:

The formatted string criterion.

validate()[source]

Checks if this fetching criterion is valid.

Note

Things that are NOT validated here: - Availability of the criterion for the mailbox of fetcher. - Existence of the criterion in general (covered by checking the above)

Raises:

ValueError – If this fetching criterion is invalid.

Return type:

None

as_imap_criterion()[source]

Returns the formatted criterion for the IMAP request, handles dates in particular.

Note

There’s no need to use timezone.now here as only the date part is used.

Return type:

str

Returns:

Formatted criterion to be used in IMAP request.

as_jmap_filter()[source]

Returns the filter-condition for the JMAP Email/query request.

Return type:

EmailQueryFilterCondition

Returns:

The filter-condition to be used in JMAP request.

as_exchange_queryset(base_query)[source]

Returns the queryset for the Exchange request.

Note

Use no timezone here to use the mailserver time settings.

Parameters:

base_query (QuerySet) – The query to extend based on the criterion.

Return type:

QuerySet

Returns:

Augmented queryset to be used in Exchange request.

property needs_argument: bool

Whether this fetching criterion requires an argument.

Returns:

Whether this fetching criterion is different after formatting.