Skip to content

Instantly share code, notes, and snippets.

@Aero-Blue
Created March 23, 2020 16:39
Show Gist options
  • Save Aero-Blue/da35ac605af254b8b4cb79fa692a10fd to your computer and use it in GitHub Desktop.
Save Aero-Blue/da35ac605af254b8b4cb79fa692a10fd to your computer and use it in GitHub Desktop.
Parse bytes into message objects for further manipulation
def get_raw_messages(server):
message_ids = [
int(message_id.split(b" ")[0]) for message_id in server.list()[1]
]
raw_messages = [
b"\n".join(server.retr(message_id)[1]) for message_id in message_ids
]
return [
parser.BytesParser().parsebytes(raw_message) for raw_message in raw_messages
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment