diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2017-07-24 11:26:39 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2017-07-24 11:33:29 -0400 |
| commit | 3a8225c6816d941c6c079af256cc57b143296efc (patch) | |
| tree | 1a24361505275f7bea2e9bae6959942980d4a87b | |
| parent | 34b4b25a2fc9f317a88c48ea8beb93ef1c32740e (diff) | |
| download | famille-flask-3a8225c6816d941c6c079af256cc57b143296efc.tar.gz | |
fix
| -rw-r--r-- | email_helpers.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/email_helpers.py b/email_helpers.py index eeb2168..a3e2b29 100644 --- a/email_helpers.py +++ b/email_helpers.py @@ -134,13 +134,13 @@ if __name__ == "__main__": "(date, news_id, user_id, content, content_cache) " \ "VALUES(?, ?, ?, ?, ?)" try: - with open('.pickle') as fh: + with open('.pickle', 'rb') as fh: already_seen = pickle.load(fh) except FileNotFoundError: already_seen = set() for msg_id in ListMessagesWithLabels(GmailMessage._service, 'me', 'INBOX'): - if msg_id in already_seen: + if msg_id['id'] in already_seen: continue mail = GmailMessage.from_id(msg_id['id']) m = regex.match(mail['To']) @@ -169,4 +169,5 @@ if __name__ == "__main__": db.commit() print(msg_id['id'], news_id, email_addr, date, comment) already_seen.add(msg_id['id']) - pickle.dump(already_seen, '.pickle') + with open('.pickle', 'wb') as fh: + pickle.dump(already_seen, fh) |
