<commit_before>"""
Russian-specific forms helpers
"""
from __future__ import absolute_import

import re

from django.contrib.localflavor.ru.ru_regions import RU_COUNTY_CHOICES, RU_REGIONS_CHOICES
from django.forms.fields import RegexField, Select
from django.utils.translation import ugettext_lazy as _


phone_digits_re = re.compile(r'^(?:[78]-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$')

class RUCountySelect(Select):
    """
    A Select widget that uses a list of Russian Counties as its choices.
    """
    def __init__(self, attrs=None):
        super(RUCountySelect, self).__init__(attrs, choices=RU_COUNTY_CHOICES)


class RURegionSelect(Select):
    """
    A Select widget that uses a list of Russian Regions as its choices.
    """
    def __init__(self, attrs=None):
        super(RURegionSelect, self).__init__(attrs, choices=RU_REGIONS_CHOICES)


class RUPostalCodeField(RegexField):
    """
    Russian Postal code field.
    Format: XXXXXX, where X is any digit, and first digit is not zero.
    """
    default_error_messages = {
        'invalid': _(u'Enter a postal code in the format XXXXXX.'),
    }
    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
        super(RUPostalCodeField, self).__init__(r'^\d{6}$',
            max_length, min_length, *args, **kwargs)


class RUPassportNumberField(RegexField):
    """
    Russian internal passport number format:
    XXXX XXXXXX where X - any digit.
    """
    default_error_messages = {
        'invalid': _(u'Enter a passport number in the format XXXX XXXXXX.'),
    }
    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
        super(RUPassportNumberField, self).__init__(r'^\d{4} \d{6}$',
            max_length, min_length, *args, **kwargs)


class RUAlienPassportNumberField(RegexField):
    """
    Russian alien's passport number format:
    XX XXXXXXX where X - any digit.
    """
    default_error_messages = {
        'invalid': _(u'Enter a passport number in the format XX XXXXXXX.'),
    }
    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
        super(RUAlienPassportNumberField, self).__init__(r'^\d{2} \d{7}$',
            max_length, min_length, *args, **kwargs)<commit_msg>Fixed #18269 -- Applied unicode_literals for Python 3 compatibility.<commit_after>"""
Russian-specific forms helpers
"""
from __future__ import absolute_import, unicode_literals

import re

from django.contrib.localflavor.ru.ru_regions import RU_COUNTY_CHOICES, RU_REGIONS_CHOICES
from django.forms.fields import RegexField, Select
from django.utils.translation import ugettext_lazy as _


phone_digits_re = re.compile(r'^(?:[78]-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$')

class RUCountySelect(Select):
    """
    A Select widget that uses a list of Russian Counties as its choices.
    """
    def __init__(self, attrs=None):
        super(RUCountySelect, self).__init__(attrs, choices=RU_COUNTY_CHOICES)


class RURegionSelect(Select):
    """
    A Select widget that uses a list of Russian Regions as its choices.
    """
    def __init__(self, attrs=None):
        super(RURegionSelect, self).__init__(attrs, choices=RU_REGIONS_CHOICES)


class RUPostalCodeField(RegexField):
    """
    Russian Postal code field.
    Format: XXXXXX, where X is any digit, and first digit is not zero.
    """
    default_error_messages = {
        'invalid': _('Enter a postal code in the format XXXXXX.'),
    }
    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
        super(RUPostalCodeField, self).__init__(r'^\d{6}$',
            max_length, min_length, *args, **kwargs)


class RUPassportNumberField(RegexField):
    """
    Russian internal passport number format:
    XXXX XXXXXX where X - any digit.
    """
    default_error_messages = {
        'invalid': _('Enter a passport number in the format XXXX XXXXXX.'),
    }
    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
        super(RUPassportNumberField, self).__init__(r'^\d{4} \d{6}$',
            max_length, min_length, *args, **kwargs)


class RUAlienPassportNumberField(RegexField):
    """
    Russian alien's passport number format:
    XX XXXXXXX where X - any digit.
    """
    default_error_messages = {
        'invalid': _('Enter a passport number in the format XX XXXXXXX.'),
    }
    def __init__(self, max_length=None, min_length=None, *args, **kwargs):
        super(RUAlienPassportNumberField, self).__init__(r'^\d{2} \d{7}$',
            max_length, min_length, *args, **kwargs)
{'fraction_non_alphanumeric': 0.12781456953642384, 'fraction_numerical': 0.005739514348785872, 'mean_word_length': 3.685625646328852, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '7495425', 'n_tokens_mistral': 1515, 'n_tokens_neox': 1444, 'n_words': 375}