def get_mailbox_list(server: imaplib.IMAP4) -> List[str]: """ Return a list of usable mailbox names """ resp = [] for mb in check_response(server.list()): bits = parse_list_response(mb) if rb"\\Noselect" not in bits[0]: resp.append(bits[2].decode()) return resp
def get_mailbox_list(server: imaplib.IMAP4, directory: str = '""', pattern: str = '"*"') -> List[str]: """ Return a list of usable mailbox names which match the pattern. """ resp = [] for mb in check_response(server.list(directory, pattern)): bits = parse_list_response(mb) if rb"\\Noselect" not in bits[0]: resp.append(bits[2].decode()) return resp
def run(self, imap_obj: imaplib.IMAP4): """Runs LIST command. Raises: - ImapRuntimeError - if command executions failed :param imap_obj: imaplib.IMAP4 :return: iterable with ImapFolder items """ typ, data = imap_obj.list(self.__directory, self.__pattern) self.check_response(typ, data) for line in filter(None, data): yield ImapFolder.build(line)