'Tries to set filename extension from mime-type'

def filename_ext_from_mime(self, entry):

    extensions = mimetypes.guess_all_extensions(entry[u'mime-type'], strict=False)
    if extensions:
        log.debug(u'Mimetype    guess    for    %s    is    %s    ', entry[u'mime-type'], extensions)
        if entry.get(u'filename'):
            if any((entry[u'filename'].endswith(extension) for extension in extensions)):
                log.debug(u'Filename    %s    extension    matches    to    mime-type', entry[u'filename'])
            else:
                extension = mimetypes.guess_extension(entry[u'mime-type'], strict=False)
                log.debug(u'Adding    mime-type    extension    %s    to    %s', extension, entry[u'filename'])
                entry[u'filename'] = (entry[u'filename'] + extension)
    else:
        log.debug(u"Python    doesn't    know    extension    for    mime-type:    %s", entry[u'mime-type'])
