diff options
-rw-r--r-- | alot/helper.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/alot/helper.py b/alot/helper.py index b12b7cb5..61a0ff37 100644 --- a/alot/helper.py +++ b/alot/helper.py @@ -258,6 +258,20 @@ def guess_mimetype(blob): return m.buffer(blob) +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 + """ + m = magic.open(magic.MAGIC_MIME_ENCODING) + m.load() + return m.buffer(blob) + + def guess_mimetype_of_path(path): """ uses file magic to determine the mime-type of a file at given path. |