summaryrefslogtreecommitdiff
path: root/alot/helper.py
diff options
context:
space:
mode:
Diffstat (limited to 'alot/helper.py')
-rw-r--r--alot/helper.py40
1 files changed, 0 insertions, 40 deletions
diff --git a/alot/helper.py b/alot/helper.py
index 08df3667..43732b24 100644
--- a/alot/helper.py
+++ b/alot/helper.py
@@ -6,12 +6,9 @@
from collections import deque
import logging
import os
-import re
import shlex
import email
-import magic
-
def split_commandline(s):
"""
@@ -120,43 +117,6 @@ def shorten_author_string(authors_string, maxlength):
authorsstring = ', '.join(authors_chain)
return authorsstring
-
-def guess_mimetype(blob):
- """
- uses file magic to determine the mime-type of the given data blob.
-
- :param blob: file content as read by file.read()
- :type blob: data
- :returns: mime-type, falls back to 'application/octet-stream'
- :rtype: str
- """
- mimetype = 'application/octet-stream'
- # 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_TYPE)
- m.load()
- magictype = m.buffer(blob)
- elif hasattr(magic, 'from_buffer'):
- # cf. issue #841
- magictype = magic.from_buffer(blob, mime=True) or magictype
- else:
- raise Exception('Unknown magic API')
-
- # libmagic does not always return proper mimetype strings, cf. issue #459
- if re.match(r'\w+\/\w+', magictype):
- mimetype = magictype
- return mimetype
-
def shell_quote(text):
"""Escape the given text for passing it to the shell for interpretation.
The resulting string will be parsed into one "word" (in the sense used in