pymap.listtree

class pymap.listtree.ListEntry(name, exists, marked, has_children)[source]

An entry in the list results.

Parameters:
  • name (str) – The name of the mailbox.

  • exists (bool) – False if the mailbox should be marked \Noselect.

  • marked (bool | None) – True, False, or None if the mailbox should be marked with \Marked, \Unmarked , or neither, respectively.

  • has_children (bool) – Whether the mailbox should be marked \HasChildren or \HasNoChildren.

property attributes: Sequence[bytes]

The mailbox attributes that should be returned with the mailbox in a LIST response, e.g. \Noselect.

See also

RFC 3348

class pymap.listtree.ListTree(delimiter)[source]

Constructs a tree of hierarchical mailbox names. If a mailbox name has superior names in the heirarchy that do not exist, they are added as “unreferenced”.

Parameters:

delimiter (str) – The string delimiter for nested mailbox parts.

update(*names)[source]

Add all the mailbox names to the tree, filling in any missing nodes.

Parameters:

names (str) – The names of the mailboxes.

Return type:

ListTree

set_marked(name, marked=False, unmarked=False)[source]

Add or remove the \Marked and \Unmarked mailbox attributes.

Parameters:
  • name (str) – The name of the mailbox.

  • marked (bool) – True if the \Marked attribute should be added.

  • unmarked (bool) – True if the \Unmarked attribute should be added.

Return type:

None

get(name)[source]

Return the named entry in the list tree.

Parameters:

name (str) – The entry name.

Return type:

ListEntry | None

get_renames(from_name, to_name)[source]

Return a list of tuples for all mailboxes that must be renamed, for the given rename operation. This should include (from_name, to_name) as well as all inferior names in the heirarchy that must also be renamed. If from_name does not exist, an empty list is returned.

See also

RFC 3501 6.3.5

Parameters:
  • from_name (str) – The original name of the mailbox.

  • to_name (str) – The intended new name of the mailbox.

Return type:

Sequence[tuple[str, str]]

list()[source]

Return all the entries in the list tree.

Return type:

Iterable[ListEntry]

list_matching(ref_name, filter_)[source]

Return all the entries in the list tree that match the given query.

Parameters:
  • ref_name (str) – Mailbox reference name.

  • filter – Mailbox name with possible wildcards.

  • filter_ (str)

Return type:

Iterable[ListEntry]