Remove email.Parse

The Parse funcion was deprecated in python 2.4. We can use this new
code.
This commit is contained in:
Rodolfo García Peñas (kix) 2020-10-12 12:40:54 +02:00
parent 62df6e70c3
commit ba6857bc87

View File

@ -366,9 +366,8 @@ class MaildirFolder(BaseFolder):
content, 'Delivery-date') content, 'Delivery-date')
except Exception as e: except Exception as e:
# This should never happen. # This should never happen.
from email.Parser import Parser
from offlineimap.ui import getglobalui from offlineimap.ui import getglobalui
datestr = Parser().parsestr(content, True).get("Date") datestr = emailutil.get_message_date(content)
ui = getglobalui() ui = getglobalui()
ui.warn("UID %d has invalid date %s: %s\n" ui.warn("UID %d has invalid date %s: %s\n"
"Not using message timestamp as file prefix" % "Not using message timestamp as file prefix" %
@ -387,9 +386,8 @@ class MaildirFolder(BaseFolder):
# In case date is wrongly so far into the future as to be > max # In case date is wrongly so far into the future as to be > max
# int32. # int32.
except Exception as e: except Exception as e:
from email.Parser import Parser
from offlineimap.ui import getglobalui from offlineimap.ui import getglobalui
datestr = Parser().parsestr(content, True).get("Date") datestr = emailutil.get_message_date(content)
ui = getglobalui() ui = getglobalui()
ui.warn("UID %d has invalid date %s: %s\n" ui.warn("UID %d has invalid date %s: %s\n"
"Not changing file modification time" % (uid, datestr, e)) "Not changing file modification time" % (uid, datestr, e))