<commit_before># -*- coding: utf-8 -*-

from __future__ import absolute_import

import logging
import traceback

import six

from . import core


class ExceptionToSoapFault(object):

    def __init__(self, traceback=False):
        self.traceback = traceback

    def __call__(self, request, next_call):
        try:
            return next_call(request)
        except Exception as e:
            if self.traceback:
                message = traceback.format_exc()
            else:
                message = '%s: %s' % (e.__class__.__name__, e)
            if six.PY2:
                message = message.decode('utf8')
            return core.SOAPError(request.dispatcher.service.version.Code.SERVER, message)


class ExceptionLogger(object):

    def __init__(self, logger=None, exceptions=(Exception,), traceback=True):
        self.logger = logger if logger is not None else logging.getLogger(__name__)
        self.traceback = traceback<commit_msg>middlewares: exceptions must be a tuple in logger middleware.<commit_after># -*- coding: utf-8 -*-

from __future__ import absolute_import

import logging
import traceback

import six

from . import core


class ExceptionToSoapFault(object):

    def __init__(self, traceback=False):
        self.traceback = traceback

    def __call__(self, request, next_call):
        try:
            return next_call(request)
        except Exception as e:
            if self.traceback:
                message = traceback.format_exc()
            else:
                message = '%s: %s' % (e.__class__.__name__, e)
            if six.PY2:
                message = message.decode('utf8')
            return core.SOAPError(request.dispatcher.service.version.Code.SERVER, message)


class ExceptionLogger(object):

    def __init__(self, logger=None, exceptions=(Exception,), traceback=True):
        if not isinstance(exceptions, tuple):
            raise TypeError('exceptions must be a tuple.')
        self.logger = logger if logger is not None else logging.getLogger(__name__)
        self.traceback = traceback
{'fraction_non_alphanumeric': 0.09276347741622147, 'fraction_numerical': 0.0029140359397765905, 'mean_word_length': 2.5334476843910805, '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': '1744444', 'n_tokens_mistral': 570, 'n_tokens_neox': 553, 'n_words': 155}