<commit_before>from __future__ import absolute_import
import contextlib
import types


@contextlib.contextmanager
def ignore(*exceptions):
    exceptions = exceptions or Exception
    try:
        yield
    except exceptions:
        pass
    except:
        raise


@contextlib.contextmanager
def update(fn_or_str, *exceptions):
    try:
        yield
    except Exception as e:
        if type(e) in exceptions:
            try:
                msg = e.args[0]
            except:
                msg = ''
            if isinstance(fn_or_str, types.FunctionType):
                e.args = (fn_or_str(msg),) + e.args[1:]
            else:
                e.args = (msg + fn_or_str,) + e.args[1:]
        raise<commit_msg>exceptions.update takes an optional predicate<commit_after>from __future__ import absolute_import
import contextlib
import types


@contextlib.contextmanager
def ignore(*exceptions):
    exceptions = exceptions or Exception
    try:
        yield
    except exceptions:
        pass
    except:
        raise


@contextlib.contextmanager
def update(fn_or_str, *exceptions, **kw):
    try:
        yield
    except Exception as e:
        if type(e) in exceptions or not exceptions:
            try:
                msg = e.args[0]
            except:
                msg = ''
            if kw.get('when', lambda x: True)(msg):
                if isinstance(fn_or_str, types.FunctionType):
                    e.args = (fn_or_str(msg),) + e.args[1:]
                else:
                    e.args = (msg + fn_or_str,) + e.args[1:]
        raise
{'fraction_non_alphanumeric': 0.08928571428571429, 'fraction_numerical': 0.003826530612244898, 'mean_word_length': 1.8118279569892473, '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': '3047789', 'n_tokens_mistral': 459, 'n_tokens_neox': 439, 'n_words': 118}