Skip to content

Commit

Permalink
Fixed MailBoxFolderManager.list bug on delim = NIL
Browse files Browse the repository at this point in the history
  • Loading branch information
ikvk committed Oct 6, 2020
1 parent 8f8bdb7 commit d4cf4d2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ Big thanks to people who helped develop this library:
`mwherman95926 <https://github.com/mwherman95926>`_,
`andyfensham <https://github.com/andyfensham>`_,
`mike-code <https://github.com/mike-code>`_,
`aknrdureegaesr <https://github.com/aknrdureegaesr>`_
`aknrdureegaesr <https://github.com/aknrdureegaesr>`_,
`ktulinger <https://github.com/ktulinger>`_

💰 You may `thank me <https://github.com/ikvk/imap_tools/blob/master/docs/donate.rst>`_, if this library helped you.
4 changes: 4 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.25.1
======
* Fixed MailBoxFolderManager.list bug on delim = NIL

0.25.0
======
* Added MailMessage.size attribute
Expand Down
2 changes: 1 addition & 1 deletion imap_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .folder import MailBoxFolderManager, MailBoxFolderStatusOptions
from .errors import *

__version__ = '0.25.0'
__version__ = '0.25.1'
6 changes: 4 additions & 2 deletions imap_tools/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ def list(self, folder: str or bytes = '', search_args: str = '*', subscribed_onl
:param subscribed_only: bool - get only subscribed folders
:return: [dict(
name: str - folder name,
delim: str - delimiter,
delim: str - delimiter, a character used to delimit levels of hierarchy in a mailbox name
flags: tuple(str) - folder flags,
)]
A 'NIL' delimiter means that no hierarchy exists, the name is a "flat" name.
"""
folder_item_re = re.compile(r'\((?P<flags>[\S ]*)\) "(?P<delim>[\S ]+)" (?P<name>.+)')
folder_item_re = re.compile(r'\((?P<flags>[\S ]*)\) (?P<delim>[\S]+) (?P<name>.+)')
command = 'LSUB' if subscribed_only else 'LIST'
typ, data = self.mailbox.box._simple_command(
command, self._encode_folder(folder), self._encode_folder(search_args))
Expand All @@ -134,5 +135,6 @@ def list(self, folder: str or bytes = '', search_args: str = '*', subscribed_onl
else:
continue
folder_dict['flags'] = tuple(folder_dict['flags'].split()) # noqa
folder_dict['delim'] = folder_dict['delim'].replace('"', '')
result.append(folder_dict)
return result

0 comments on commit d4cf4d2

Please sign in to comment.