<commit_before>from __future__ import absolute_import, unicode_literals

import six


class TembaException(Exception):
    def __unicode__(self):  # pragma: no cover
        return self.message

    def __str__(self):
        return six.text_type(self.__unicode__())


class TembaConnectionError(TembaException):
    message = "Unable to connect to host"


class TembaBadRequestError(TembaException):
    def __init__(self, errors):
        self.errors = errors

    def __unicode__(self):
        msgs = []
        if isinstance(self.errors, dict):
            for field, field_errors in six.iteritems(self.errors):
                if isinstance(field_errors, basestring):  # e.g. {"detail": "message..."}
                    msgs.append(field_errors)
                else:
                    for error in field_errors:  # e.g. {"field1": ["msg1...", "msg2..."]}
                        msgs.append(error)
        elif isinstance(self.errors, list):
            msgs = self.errors

        return msgs[0] if len(msgs) == 1 else ". ".join(msgs)

<commit_msg>Fixed text issue with Python 3<commit_after>from __future__ import absolute_import, unicode_literals

import six


class TembaException(Exception):
    def __unicode__(self):  # pragma: no cover
        return self.message

    def __str__(self):
        return six.text_type(self.__unicode__())


class TembaConnectionError(TembaException):
    message = "Unable to connect to host"


class TembaBadRequestError(TembaException):
    def __init__(self, errors):
        self.errors = errors

    def __unicode__(self):
        msgs = []
        if isinstance(self.errors, dict):
            for field, field_errors in six.iteritems(self.errors):
                if isinstance(field_errors, six.string_types):  # e.g. {"detail": "message..."}
                    msgs.append(field_errors)
                else:
                    for error in field_errors:  # e.g. {"field1": ["msg1...", "msg2..."]}
                        msgs.append(error)
        elif isinstance(self.errors, list):
            msgs = self.errors

        return msgs[0] if len(msgs) == 1 else ". ".join(msgs)


{'fraction_non_alphanumeric': 0.11163007940214853, 'fraction_numerical': 0.005137786081270434, 'mean_word_length': 2.300462249614792, 'pattern_counts': {'":': 4, '<': 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': '1045912', 'n_tokens_mistral': 639, 'n_tokens_neox': 600, 'n_words': 155}