import mimetypes


def _guess_doc_mimetype(filename):
    """
    Guess the MIME type of a document.
    """
    # Python mimetypes library expects a filename, so we have to build a
    # filename from the extension taken from Weboob data.
    guessed_mime = mimetypes.guess_type(filename)
    return guessed_mime[0] if guessed_mime[0] else 'application/octet-stream'