Created
March 23, 2020 16:39
-
-
Save Aero-Blue/da35ac605af254b8b4cb79fa692a10fd to your computer and use it in GitHub Desktop.
Parse bytes into message objects for further manipulation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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