<commit_before>import calendar
import copy
import datetime
from collections import defaultdict

from django.core.exceptions import ValidationError
from django.forms import MultipleChoiceField
from django.forms.fields import CallableChoiceIterator
from django.utils import timezone
from django.utils.encoding import force_str, force_text, smart_text

from .widgets.calendar import CalendarCheckboxSelectMultiple


class CalendarMultipleChoiceField(MultipleChoiceField):
    """
    choices = ((value1, label1), ...)
    disables = (
        (value1: [date1, ...]),
        ...
    )
    """
    widget = CalendarCheckboxSelectMultiple

    def __init__(self, choices=(), required=True, widget=None,
                 label=None, initial=None, help_text='',
                 year=None, month=None, disables=(),
                 date_format=None, day_abbr=None, *args, **kwargs):
        super().__init__(required=required, widget=widget, label=label,
                         initial=initial, help_text=help_text, *args, **kwargs)
        self.choices = choices
        if year is None:
            year = timezone.now().year
        if month is None:
            month = timezone.now().month
        self.year = year
        self.month = month
        self.disables = disables
        if date_format is not None:
            self.date_format = date_format
        else:
            self.date_format = '%Y%m%d'
        if day_abbr is not None:
            self.day_abbr = day_abbr
        else:
            self.day_abbr = calendar.day_abbr

    def __deepcopy__(self, memo):
        result = super().__deepcopy__(memo)
        result._disables = copy.deepcopy(self._disables, memo)
        result._day_abbr = copy.deepcopy(self._day_abbr, memo)
        return result

    def _get_disables(self):
        return self._disables

    def _set_disables(self, value):
        if callable(value):
            value = CallableChoiceIterator(value)
        else:<commit_msg>曜日をi18n対応<commit_after>import copy
import datetime
from collections import defaultdict

from django.core.exceptions import ValidationError
from django.forms import MultipleChoiceField
from django.forms.fields import CallableChoiceIterator
from django.utils import timezone
from django.utils.encoding import force_str, force_text, smart_text
from django.utils.translation import ugettext as _

from .widgets.calendar import CalendarCheckboxSelectMultiple


class CalendarMultipleChoiceField(MultipleChoiceField):
    """
    choices = ((value1, label1), ...)
    disables = (
        (value1: [date1, ...]),
        ...
    )
    """
    widget = CalendarCheckboxSelectMultiple

    def __init__(self, choices=(), required=True, widget=None,
                 label=None, initial=None, help_text='',
                 year=None, month=None, disables=(),
                 date_format=None, day_abbr=None, *args, **kwargs):
        super().__init__(required=required, widget=widget, label=label,
                         initial=initial, help_text=help_text, *args, **kwargs)
        self.choices = choices
        if year is None:
            year = timezone.now().year
        if month is None:
            month = timezone.now().month
        self.year = year
        self.month = month
        self.disables = disables
        if date_format is not None:
            self.date_format = date_format
        else:
            self.date_format = '%Y%m%d'
        if day_abbr is not None:
            self.day_abbr = day_abbr
        else:
            self.day_abbr = [
                _('Mon'), _('Tue'), _('Wed'),
                _('Thu'), _('Fri'), _('Sat'), _('Sun'),
            ]

    def __deepcopy__(self, memo):
        result = super().__deepcopy__(memo)
        result._disables = copy.deepcopy(self._disables, memo)
        result._day_abbr = copy.deepcopy(self._day_abbr, memo)
        return result

    def _get_disables(self):
        return self._disables

    def _set_disables(self, value):
        if callable(value):
            value = CallableChoiceIterator(value)
        else:
{'fraction_non_alphanumeric': 0.09948288598867273, 'fraction_numerical': 0.002462447672986949, 'mean_word_length': 2.419191919191919, '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': '7535436', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1127, 'n_words': 274}