OkCupid-Message-Downloader
OkCupid-Message-Downloader copied to clipboard
Threads without parseable dates crash on sort with `--directory`
Some message threads do not have proper dates, and will have the timestamp value None. The reason is unknown, but the case needs to be handled by the --directory option which does sorting by date. Not handling it crashes okcmd before messages are written to disk.
Traceback (most recent call last):
File ".../OkCupid-Message-Downloader/src/arrow_fetcher.py", line 423, in <module>
main()
File ".../OkCupid-Message-Downloader/src/arrow_fetcher.py", line 419, in main
state.fetch()
File ".../OkCupid-Message-Downloader/src/arrow_fetcher.py", line 336, in fetch
arrow_fetcher.write_directory(self.directory)
File ".../OkCupid-Message-Downloader/src/arrow_fetcher.py", line 187, in write_directory
self.messages.sort(key = lambda message: message.timestamp) # sort by time
TypeError: can't compare datetime.datetime to NoneType
Some parts of the code use a dummy/placeholder date, but would rather have None signify "not a valid date" and then take that case into account where necessary.