pymap.flags
Defines convenience classes for working with IMAP flags.
-
class pymap.flags.FlagOp(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Types of operations when updating flags.
-
REPLACE = 1
All existing flags should be replaced with the flag set.
-
ADD = 2
The flag set should be added to the existing set.
-
DELETE = 3
The flag set should be removed from the existing set.
-
apply(flag_set, operand)[source]
Apply the flag operation on the two sets, returning the result.
- Parameters:
-
- Return type:
frozenset[Flag]
-
class pymap.flags.PermanentFlags(defined)[source]
Keeps track of the defined permanent flags on a mailbox. Because the
permanent flags can include the special \*
wildcard flag, a simple
set intersect operation is not enough to filter out unknown permanent
flags.
- Parameters:
defined (Iterable[Flag]) – The defined session flags for the mailbox.
-
property defined: frozenset[Flag]
The defined permanent flags for the mailbox.
-
intersect(other)[source]
Returns the subset of flags in other
that are also in
defined
. If the wildcard flag is defined, then all flags in
other
are returned.
The &
operator is an alias of this method, making these two
calls equivalent:
perm_flags.intersect(other_flags)
perm_flags & other_flags
- Parameters:
other (Iterable[Flag]) – The operand flag set.
- Return type:
frozenset[Flag]
-
class pymap.flags.SessionFlags(defined)[source]
Used to track session flags on a message. Session flags are only valid
for the current IMAP client connection while it has the mailbox selected,
they do not persist. The \Recent
flag is a special-case session flag.
- Parameters:
defined (Iterable[Flag]) – The defined session flags for the mailbox.
-
property defined: frozenset[Flag]
The defined session flags for the mailbox.
-
intersect(other)[source]
Returns the subset of flags in other
that are also in
defined
. If the wildcard flag is defined, then all flags in
other
are returned.
The &
operator is an alias of this method, making these two
calls equivalent:
session_flags.intersect(other_flags)
session_flags & other_flags
- Parameters:
other (Iterable[Flag]) – The operand flag set.
- Return type:
frozenset[Flag]
-
get(uid)[source]
Return the session flags for the mailbox session.
- Parameters:
uid (int) – The message UID value.
- Return type:
frozenset[Flag]
-
remove(uids)[source]
Remove any session flags for the given message.
- Parameters:
uids (Iterable[int]) – The message UID values.
- Return type:
None
-
update(uid, flag_set, op=FlagOp.REPLACE)[source]
Update the flags for the session, returning the resulting flags.
- Parameters:
uid (int) – The message UID value.
flag_set (Iterable[Flag]) – The set of flags for the update operation.
op (FlagOp) – The type of update.
- Return type:
frozenset[Flag]
-
add_recent(uid)[source]
Adds the \Recent
flag to the flags for the session.
- Parameters:
uid (int) – The message UID value.
- Return type:
None
-
property recent: int
The number of messages with the \Recent
flag.
-
property recent_uids: Set[int]
The message UIDs with the \Recent
flag.
-
property flags: Mapping[int, frozenset[Flag]]
The mapping of UID to its associated session flags, not including
\Recent
.