Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Email gateway - folders

Entity: fetchmail.server

Compute Method: _compute_folders_available

Inputs Method Outputs
  • state
"""Retrieve available folders from IMAP server."""
def parse_list_response(line):
            string_line = line.decode("utf-8")
            flags, delimiter, mailbox_name = list_response_pattern.match(
                string_line
            ).groups()
            mailbox_name = mailbox_name.strip('"')
            return (flags, delimiter, mailbox_name)
for this in self:
            if this.state != "done":
                this.folders_available = _("Confirm connection first.")
                continue
            connection = this.connect()
            list_result = connection.list()
            if list_result[0] != "OK":
                this.folders_available = _("Unable to retrieve folders.")
                continue
            folders_available = []
            for folder_entry in list_result[1]:
                folders_available.append(parse_list_response(folder_entry)[2])
            this.folders_available = "\n".join(folders_available)
            connection.logout()

Back to entity