Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fix_body(body: str) -> str:
- lines = body.splitlines()
- # aws caps lines at 76.
- # line continuations are marked with =\n
- # cant do a simple find replace because
- # we only want to do it in position 76
- i = len(lines) - 2
- while i > 0:
- if lines[i][75:] == '=':
- lines[i] = lines[i][:75] + lines[i+1]
- del lines[i+1]
- body = '\n'.join(body)
- return body
- def parse_reply(raw_email: str) -> str:
- message: Message = EMAIL_PARSER.parsestr(raw_email)
- body: Message = get_email_body(message)
- body: str = fix_body(body.get_payload())
- reply: str = EmailReplyParser.parse_reply(body)
- reply = re.sub(r'\b\n\b', ' ', reply)
- return reply
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement