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
MailSelector
instance provides the following attributes:
mails
¶Currently selected
list()
store
¶Linked
PostqueueStore
at theMailSelector
instance 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
MailSelector
instance 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 thefilters
attribute.
MailSelector.
reset
()[source]¶Reset mail selector with initial store mails list.
Selected
mails
attribute is removed for memory releasing purpose (with help ofgc.collect()
). Attributemails
is then reinitialized a copy ofstore
’smails
attribute.Registered
filters
are also emptied.
MailSelector.
replay_filters
()[source]¶Reset selection with store content and replay registered filters.
Like with the
reset()
method, selectedstore
’smails
attribute.However, registered
filters
are 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
partial
allow lookup of partial sender like@domain.com
orsender@
. By default,partial
isFalse
and selection is made on exact sender.Note
Matches are made against
Mail.sender
attribute 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
partial
allow lookup of partial sender like@domain.com
orsender@
. By default,partial
isFalse
and selection is made on exact sender.Note
Matches are made against
Mail.recipients
attribute 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
smin
andsmax
are optionnal and default is set to0
. Maximum size is ignored if setted to0
. If bothsmin
andsmax
are setted to0
, no filtering is done and the entire
Parameters: Returns: List of newly selected
Return type:
list()