summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-11-20 11:42:52 +0100
committerAnton Khirnov <anton@khirnov.net>2021-11-20 11:42:52 +0100
commit69d88aa3c882cfc28ff6f4f2e558e8058d331884 (patch)
treebf7726fcc0b0890548c56a7a8a4c57bc3b2d587a
parentc6c604ab535584044dfe37a0f9abf3bcc74fe42e (diff)
envelope: drop unused code
-rw-r--r--alot/mail/envelope.py58
1 files changed, 0 insertions, 58 deletions
diff --git a/alot/mail/envelope.py b/alot/mail/envelope.py
index ad5f2ee4..55b3f7ff 100644
--- a/alot/mail/envelope.py
+++ b/alot/mail/envelope.py
@@ -12,7 +12,6 @@ import email.charset as charset
from urllib.parse import unquote
import gpg
-import magic
from .attachment import Attachment
from .. import __version__
@@ -23,63 +22,6 @@ from ..errors import GPGProblem, GPGCode
charset.add_charset('utf-8', charset.QP, charset.QP, 'utf-8')
-def _libmagic_version_at_least(version):
- """
- checks if the libmagic library installed is more recent than a given
- version.
-
- :param version: minimum version expected in the form XYY (i.e. 5.14 -> 514)
- with XYY >= 513
- """
- if hasattr(magic, 'open'):
- magic_wrapper = magic._libraries['magic']
- elif hasattr(magic, 'from_buffer'):
- magic_wrapper = magic.libmagic
- else:
- raise Exception('Unknown magic API')
-
- if not hasattr(magic_wrapper, 'magic_version'):
- # The magic_version function has been introduced in libmagic 5.13,
- # if it's not present, we can't guess right, so let's assume False
- return False
-
- # Depending on the libmagic/ctypes version, magic_version is a function or
- # a callable:
- if callable(magic_wrapper.magic_version):
- return magic_wrapper.magic_version() >= version
-
- return magic_wrapper.magic_version >= version
-
-def _guess_encoding(blob):
- """
- uses file magic to determine the encoding of the given data blob.
-
- :param blob: file content as read by file.read()
- :type blob: data
- :returns: encoding
- :rtype: str
- """
- # this is a bit of a hack to support different versions of python magic.
- # Hopefully at some point this will no longer be necessary
- #
- # the version with open() is the bindings shipped with the file source from
- # http://darwinsys.com/file/ - this is what is used by the python-magic
- # package on Debian/Ubuntu. However it is not available on pypi/via pip.
- #
- # the version with from_buffer() is available at
- # https://github.com/ahupp/python-magic and directly installable via pip.
- #
- # for more detail see https://github.com/pazz/alot/pull/588
- if hasattr(magic, 'open'):
- m = magic.open(magic.MAGIC_MIME_ENCODING)
- m.load()
- return m.buffer(blob)
- elif hasattr(magic, 'from_buffer'):
- m = magic.Magic(mime_encoding=True)
- return m.from_buffer(blob)
- else:
- raise Exception('Unknown magic API')
-
class Envelope:
"""
a message that is not yet sent and still editable.