From a51f7392e353a11dd8aeba53618731c63737848a Mon Sep 17 00:00:00 2001 From: Lucas Hoffmann Date: Sat, 12 Mar 2016 19:41:24 +0100 Subject: Handle deprecated option values gracefully. --- alot/account.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'alot/account.py') diff --git a/alot/account.py b/alot/account.py index bb350f99..017fa31e 100644 --- a/alot/account.py +++ b/alot/account.py @@ -65,16 +65,23 @@ class Account(object): self.signature_filename = signature_filename self.signature_as_attachment = signature_as_attachment self.sign_by_default = sign_by_default - self.encrypt_by_default = encrypt_by_default self.sent_box = sent_box self.sent_tags = sent_tags self.draft_box = draft_box self.draft_tags = draft_tags self.abook = abook - if self.encrypt_by_default == u"True" or \ - self.encrypt_by_default == u"False": - logging.debug("Deprecation warning: The format for the " - "encrypt_by_default option changed.") + # Handle encrypt_by_default in an backwards compatible way. The + # logging info call can later be upgraded to warning or error. + encrypt_by_default = encrypt_by_default.lower() + msg = "Deprecation warning: The format for the encrypt_by_default " \ + "option changed. Please use 'none', 'all' or 'trusted'." + if encrypt_by_default in (u"true", u"yes", u"1"): + encrypt_by_default = u"all" + logging.info(msg) + elif encrypt_by_default in (u"false", u"no", u"0"): + encrypt_by_default = u"none" + logging.info(msg) + self.encrypt_by_default = encrypt_by_default def get_addresses(self): """return all email addresses connected to this account, in order of -- cgit v1.2.3