diff options
author | Michael J Gruber <github@grubix.eu> | 2018-06-25 17:24:55 +0200 |
---|---|---|
committer | Michael J Gruber <github@grubix.eu> | 2018-07-11 13:31:10 +0200 |
commit | 101eef43e048247775847f35ec6d5e23bae68763 (patch) | |
tree | f71e3d05b2abeb65eb4b4507b61397d4ed014c81 /alot/db | |
parent | c9696caf678fb86944de29952eb22f86e8536b27 (diff) |
rename message_from_ functions
Our message_from_functions decrypt PGP encryped parts in addition to
creating a message object (from bytes or file handles) and recognizing
the encoding in one way or the other.
Rename them before refactoring to make their function clearer and to
distinguish them from the email.message_from_ functions (which do not
decrypt).
Diffstat (limited to 'alot/db')
-rw-r--r-- | alot/db/message.py | 2 | ||||
-rw-r--r-- | alot/db/utils.py | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/alot/db/message.py b/alot/db/message.py index 10115072..b53ec6c0 100644 --- a/alot/db/message.py +++ b/alot/db/message.py @@ -101,7 +101,7 @@ class Message(object): if not self._email: try: with open(path, 'rb') as f: - self._email = utils.message_from_bytes(f.read()) + self._email = utils.decrypted_message_from_bytes(f.read()) except IOError: self._email = email.message_from_string(warning) return self._email diff --git a/alot/db/utils.py b/alot/db/utils.py index d7c56310..35cd4250 100644 --- a/alot/db/utils.py +++ b/alot/db/utils.py @@ -179,7 +179,7 @@ def _handle_encrypted(original, message): # recovered plain text mail. maybe that's a feature. malformed = str(e) else: - n = message_from_bytes(d) + n = decrypted_message_from_bytes(d) # add the decrypted message to message. note that n contains all # the attachments, no need to walk over n here. @@ -214,7 +214,7 @@ def _handle_encrypted(original, message): original.attach(content) -def message_from_file(handle): +def decrypted_message_from_file(handle): '''Reads a mail from the given file-like object and returns an email object, very much like email.message_from_file. In addition to that OpenPGP encrypted data is detected and decrypted. If this @@ -263,7 +263,7 @@ def message_from_file(handle): return m -def message_from_string(s): +def decrypted_message_from_string(s): '''Reads a mail from the given string. This is the equivalent of :func:`email.message_from_string` which does nothing but to wrap the given string in a StringIO object and to call @@ -273,17 +273,17 @@ def message_from_string(s): details. ''' - return message_from_file(io.StringIO(s)) + return decrypted_message_from_file(io.StringIO(s)) -def message_from_bytes(bytestring): +def decrypted_message_from_bytes(bytestring): """Create a Message from bytes. Attempt to guess the encoding of the bytestring. :param bytes bytestring: an email message as raw bytes """ - return message_from_file(io.StringIO(helper.try_decode(bytestring))) + return decrypted_message_from_file(io.StringIO(helper.try_decode(bytestring))) def extract_headers(mail, headers=None): |