diff options
author | Lucas Hoffmann <l-m-h@web.de> | 2016-03-12 19:41:24 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2016-03-24 21:01:43 +0000 |
commit | a51f7392e353a11dd8aeba53618731c63737848a (patch) | |
tree | 7a37fafe4141488823a13be21b113b1a66355850 | |
parent | bb4bce29c506da51142fbf3df4b06192f293e054 (diff) |
Handle deprecated option values gracefully.
-rw-r--r-- | alot/account.py | 17 | ||||
-rw-r--r-- | alot/commands/globals.py | 3 | ||||
-rw-r--r-- | alot/defaults/alot.rc.spec | 2 |
3 files changed, 14 insertions, 8 deletions
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 diff --git a/alot/commands/globals.py b/alot/commands/globals.py index c7d041ae..519cf2aa 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -851,8 +851,7 @@ class ComposeCommand(Command): logging.debug('attaching: ' + a) # set encryption if needed - if self.encrypt or account.encrypt_by_default == u"all" or \ - account.encrypt_by_default == u"True": + if self.encrypt or account.encrypt_by_default == u"all": logging.debug("Trying to encrypt message because encrypt={} and " "encrypt_by_default={}".format( self.encrypt, account.encrypt_by_default)) diff --git a/alot/defaults/alot.rc.spec b/alot/defaults/alot.rc.spec index 18b17772..0967bf4f 100644 --- a/alot/defaults/alot.rc.spec +++ b/alot/defaults/alot.rc.spec @@ -316,7 +316,7 @@ msg_summary_hides_threadwide_tags = boolean(default=True) # compatibility to give users a change to migrate to the new # option type. They might become deprecated in future # versions. - encrypt_by_default = option('all', 'none', 'trusted', 'True', 'False', default='none') + encrypt_by_default = option('all', 'none', 'trusted', 'True', 'False', 'true', 'false', 'Yes', 'No', 'yes', 'no', '1', '0', default='none') # The GPG key ID you want to use with this account. If unset, alot will # use your default key. |