<commit_before>
from __future__ import absolute_import

from io import BytesIO
import mimetypes
import os
import re
import shutil
import tempfile

from .sh_utils import run

__all__ = ['create_thumbnail']


def create_thumbnail(source_filename, dimensions=None, **kwargs):
    assert dimensions is None
    mime_type, encoding = mimetypes.guess_type(source_filename, strict=False)
    thumbnailer = thumbnailer_for(mime_type)
    if thumbnailer is None:
        return None
    return thumbnailer.thumbnail(source_filename, dimensions, **kwargs)

<commit_msg>fix exception if no mimetype was detected<commit_after>
from __future__ import absolute_import

from io import BytesIO
import mimetypes
import os
import re
import shutil
import tempfile

from .sh_utils import run

__all__ = ['create_thumbnail']


def create_thumbnail(source_filename, dimensions=None, **kwargs):
    assert dimensions is None
    mime_type, encoding = mimetypes.guess_type(source_filename, strict=False)
    if mime_type is None:
        return None
    thumbnailer = thumbnailer_for(mime_type)
    if thumbnailer is None:
        return None
    return thumbnailer.thumbnail(source_filename, dimensions, **kwargs)


{'fraction_non_alphanumeric': 0.05956375838926174, 'fraction_numerical': 0.0, 'mean_word_length': 4.876847290640394, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3801147', 'n_tokens_mistral': 359, 'n_tokens_neox': 350, 'n_words': 110}