<commit_before>from __future__ import unicode_literals

try:
    from urllib import parse as urlparse
except ImportError:
    import urlparse   # Python 2

from django import forms
from django.db.models.fields import CharField, BLANK_CHOICE_DASH
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.html import escape as escape_html
from django.utils.functional import lazy

from django_countries import countries, ioc_data, widgets
from django_countries.conf import settings


class TemporaryEscape(object):
    __slots__ = ['country', 'original_escape']

    def __init__(self, country):
        self.country = country

    def __bool__(self):
        return self.country._escape

    __nonzero__ = __bool__

    def __enter__(self):
        self.original_escape = self.country._escape
        self.country._escape = True

    def __exit__(self, type, value, traceback):
        self.country._escape = self.original_escape


@python_2_unicode_compatible
class Country(object):

    def __init__(self, code, flag_url=None, str_attr='code'):
        self.code = code
        self.flag_url = flag_url
        self._escape = False
        self._str_attr = str_attr

    def __str__(self):
        return force_text(getattr(self, self._str_attr) or '')

    def __eq__(self, other):
        code = force_text(self.code or '')
        if code == '':
            return False
        return code == force_text(other or '')

    def __ne__(self, other):
        return not self.__eq__(other)

    def __hash__(self):
        return hash(force_text(self))

    def __repr__(self):
        args = ['code={country.code!r}']
        if self.flag_url is not None:
            args.append('flag_url={country.flag_url!r}')
        if self._str_attr != 'code':
            args.append('escape={country._str_attr!r}')
        args = ', '.join(args).format(country=self)
        return '{name}({args})'.format(name=self.__class__.__name__, args=args)
<commit_msg>Revert "Don't make a Country object ever equal anything if it's empty"<commit_after>from __future__ import unicode_literals

try:
    from urllib import parse as urlparse
except ImportError:
    import urlparse   # Python 2

from django import forms
from django.db.models.fields import CharField, BLANK_CHOICE_DASH
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.html import escape as escape_html
from django.utils.functional import lazy

from django_countries import countries, ioc_data, widgets
from django_countries.conf import settings


class TemporaryEscape(object):
    __slots__ = ['country', 'original_escape']

    def __init__(self, country):
        self.country = country

    def __bool__(self):
        return self.country._escape

    __nonzero__ = __bool__

    def __enter__(self):
        self.original_escape = self.country._escape
        self.country._escape = True

    def __exit__(self, type, value, traceback):
        self.country._escape = self.original_escape


@python_2_unicode_compatible
class Country(object):

    def __init__(self, code, flag_url=None, str_attr='code'):
        self.code = code
        self.flag_url = flag_url
        self._escape = False
        self._str_attr = str_attr

    def __str__(self):
        return force_text(getattr(self, self._str_attr) or '')

    def __eq__(self, other):
        return force_text(self.code or '') == force_text(other or '')

    def __ne__(self, other):
        return not self.__eq__(other)

    def __hash__(self):
        return hash(force_text(self))

    def __repr__(self):
        args = ['code={country.code!r}']
        if self.flag_url is not None:
            args.append('flag_url={country.flag_url!r}')
        if self._str_attr != 'code':
            args.append('escape={country._str_attr!r}')
        args = ', '.join(args).format(country=self)
        return '{name}({args})'.format(name=self.__class__.__name__, args=args)

{'fraction_non_alphanumeric': 0.09997475385003787, 'fraction_numerical': 0.0015147689977278464, 'mean_word_length': 3.2465166130760985, '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': '4367811', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1157, 'n_words': 295}