pymailq.selector – Mails queue filtering¶
The selector module mainly provide a selector class to interact with
structures from the store module.
MailSelector Objects¶
- class
selector.MailSelector(store)[source]¶Mail selector class to request mails from store matching criterias.
The
MailSelectorinstance provides the following attributes:
mails¶Currently selected
list()
store¶Linked
PostqueueStoreat theMailSelectorinstance initialization.
filters¶Applied filters
list()on current selection. Filters list entries are tuples containing(function.__name__, args, kwargs)for each applied filters. This list is filled by thefilter_registration()decorator while calling filtering methods. It is possible to replay registered filter usingreplay_filters()method.The
MailSelectorinstance provides the following methods:
MailSelector.filter_registration(function)[source]¶Decorator to register applied filter.
This decorated is used to wrap selection methods
lookup_*. It registers a(function.__name__, args, kwargs)tuple()in thefiltersattribute.
MailSelector.reset()[source]¶Reset mail selector with initial store mails list.
Selected
mailsattribute is removed for memory releasing purpose (with help ofgc.collect()). Attributemailsis then reinitialized a copy ofstore’smailsattribute.Registered
filtersare also emptied.
MailSelector.replay_filters()[source]¶Reset selection with store content and replay registered filters.
Like with the
reset()method, selectedstore’smailsattribute.However, registered
filtersare kept and replayed on resetted selection. Use this method to refresh your store content while keeping your filters.
MailSelector.get_mails_by_qids(qids)[source]¶Get mails with specified IDs.
This function is not registered as filter.
Parameters: qids (list) – List of mail IDs. Returns: List of newly selected Return type: list()
MailSelector.lookup_qids(*args, **kwargs)[source]¶Lookup mails with specified IDs.
Parameters: qids (list) – List of mail IDs. Returns: List of newly selected Return type: list()
MailSelector.lookup_status(*args, **kwargs)[source]¶Lookup mails with specified postqueue status.
Parameters: status (list) – List of matching status to filter on. Returns: List of newly selected Return type: list()
MailSelector.lookup_sender(*args, **kwargs)[source]¶Lookup mails send from a specific sender.
Optionnal parameter
partialallow lookup of partial sender like@domain.comorsender@. By default,partialisFalseand selection is made on exact sender.Note
Matches are made against
Mail.senderattribute instead of real mail header Sender.
Parameters: Returns: List of newly selected
Return type:
list()
MailSelector.lookup_recipient(*args, **kwargs)[source]¶Lookup mails send to a specific recipient.
Optionnal parameter
partialallow lookup of partial sender like@domain.comorsender@. By default,partialisFalseand selection is made on exact sender.Note
Matches are made against
Mail.recipientsattribute instead of real mail header To.
Parameters: Returns: List of newly selected
Return type:
list()
MailSelector.lookup_error(*args, **kwargs)[source]¶Lookup mails with specific error message (message may be partial).
Parameters: error_msg (str) – Error message to filter on Returns: List of newly selected Return type: list()
MailSelector.lookup_date(*args, **kwargs)[source]¶Lookup mails send on specific date range(s).
Parameters:
- start (datetime.date) – Start date (Default: None)
- stop (datetime.date) – Stop date (Default: None)
Returns: List of newly selected
Return type:
list()
MailSelector.lookup_size(*args, **kwargs)[source]¶Lookup mails send with specific size.
Both arguments
sminandsmaxare optionnal and default is set to0. Maximum size is ignored if setted to0. If bothsminandsmaxare setted to0, no filtering is done and the entire
Parameters: Returns: List of newly selected
Return type:
list()