def parse(self):
if not self.message:<EOL><INDENT>return self<EOL><DEDENT>self._reset()<EOL>parts = []  <EOL>for p in self.message.walk():<EOL><INDENT>part_content_type = p.get_content_type()<EOL>self._append_defects(p, part_content_type)<EOL>parts.append(p)<EOL><DEDENT>if self.defects_categories & EPILOGUE_DEFECTS:<EOL><INDENT>log.debug("<STR_LIT>")<EOL>epilogue = find_between(<EOL>self.message.epilogue,<EOL>"<STR_LIT:{}>".format("<STR_LIT>" + self.message.get_boundary()),<EOL>"<STR_LIT:{}>".format("<STR_LIT>" + self.message.get_boundary() + "<STR_LIT>"))<EOL>try:<EOL><INDENT>p = email.message_from_string(epilogue)<EOL>parts.append(p)<EOL><DEDENT>except TypeError:<EOL><INDENT>log.debug("<STR_LIT>")<EOL><DEDENT>except Exception:<EOL><INDENT>log.error("<STR_LIT>")<EOL><DEDENT><DEDENT>for i, p in enumerate(parts):<EOL><INDENT>if not p.is_multipart():<EOL><INDENT>filename = decode_header_part(p.get_filename())<EOL>charset = p.get_content_charset('<STR_LIT:utf-8>')<EOL>charset_raw = p.get_content_charset()<EOL>log.debug("<STR_LIT>".format(charset, i))<EOL>if filename:<EOL><INDENT>log.debug("<STR_LIT>".format(i))<EOL>log.debug("<STR_LIT>".format(filename, i))<EOL>binary = False<EOL>mail_content_type = ported_string(p.get_content_type())<EOL>log.debug("<STR_LIT>".format(<EOL>mail_content_type, i))<EOL>transfer_encoding = ported_string(<EOL>p.get('<STR_LIT>', '<STR_LIT>')).lower()<EOL>log.debug("<STR_LIT>".format(<EOL>transfer_encoding, i))<EOL>content_id = ported_string(p.get('<STR_LIT>'))<EOL>log.debug("<STR_LIT>".format(<EOL>content_id, i))<EOL>if transfer_encoding == "<STR_LIT>" or (<EOL>transfer_encoding == "<STR_LIT>" and "<STR_LIT>" in mail_content_type):<EOL><INDENT>payload = p.get_payload(decode=False)<EOL>binary = True<EOL>log.debug("<STR_LIT>".format(<EOL>filename, i))<EOL><DEDENT>else:<EOL><INDENT>payload = ported_string(<EOL>p.get_payload(decode=True), encoding=charset)<EOL>log.debug(<EOL>"<STR_LIT>".format(<EOL>filename, i))<EOL><DEDENT>self._attachments.append({<EOL>"<STR_LIT:filename>": filename,<EOL>"<STR_LIT>": payload,<EOL>"<STR_LIT>": binary,<EOL>"<STR_LIT>": mail_content_type,<EOL>"<STR_LIT>": content_id,<EOL>"<STR_LIT>": charset_raw,<EOL>"<STR_LIT>": transfer_encoding})<EOL><DEDENT>else:<EOL><INDENT>log.debug("<STR_LIT>".format(i))<EOL>payload = ported_string(<EOL>p.get_payload(decode=True), encoding=charset)<EOL>if payload:<EOL><INDENT>if p.get_content_subtype() == '<STR_LIT:html>':<EOL><INDENT>self._text_html.append(payload)<EOL><DEDENT>else:<EOL><INDENT>self._text_plain.append(payload)<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>self._mail = self._make_mail()<EOL>self._mail_partial = self._make_mail(complete=False)<EOL><DEDENT>
This method parses the raw email and makes the tokens.

Returns:
    Instance of MailParser with raw email parsed