<commit_before>import datetime
import itertools
import warnings

from ..xml import OUT
from ..users import SharePointUser
from ..utils import decode_entities
from . import moderation

empty_values = ('', None)

class FieldDescriptor(object):
    def __init__(self, field, immutable=False):
        self.field = field
        self.immutable = immutable
    def __get__(self, instance, owner):
        try:
            return self.field.descriptor_get(instance, instance._data[self.field.name])
        except KeyError:
            return None

    def __set__(self, instance, value):
        if self.immutable:
            raise AttributeError("Field '{0}' is immutable".format(self.field.name))

        new_value = self.field.descriptor_set(instance, value)
        if not self.field.is_equal(new_value, instance._data.get(self.field.name)):
            instance._data[self.field.name] = new_value
            instance._changed.add(self.field.name)

class MultiFieldDescriptor(FieldDescriptor):
    def __get__(self, instance, owner):
        try:
            values = instance.data[self.field.name]
            return [self.field.descriptor_get(instance, value) for value in values]
        except KeyError:
            raise AttributeError
    def __set__(self, instance, values):<commit_msg>More tolerant handling of missing mlti-value fields<commit_after>import datetime
import itertools
import warnings

from ..xml import OUT
from ..users import SharePointUser
from ..utils import decode_entities
from . import moderation

empty_values = ('', None)

class FieldDescriptor(object):
    def __init__(self, field, immutable=False):
        self.field = field
        self.immutable = immutable
    def __get__(self, instance, owner):
        try:
            return self.field.descriptor_get(instance, instance._data[self.field.name])
        except KeyError:
            return None

    def __set__(self, instance, value):
        if self.immutable:
            raise AttributeError("Field '{0}' is immutable".format(self.field.name))

        new_value = self.field.descriptor_set(instance, value)
        if not self.field.is_equal(new_value, instance._data.get(self.field.name)):
            instance._data[self.field.name] = new_value
            instance._changed.add(self.field.name)

class MultiFieldDescriptor(FieldDescriptor):
    def __get__(self, instance, owner):
        values = instance._data.get(self.field.name, ())
        return [self.field.descriptor_get(instance, value) for value in values]

    def __set__(self, instance, values):
{'fraction_non_alphanumeric': 0.09808518952715904, 'fraction_numerical': 0.0007815552950371239, 'mean_word_length': 3.0764331210191083, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1174532', 'n_tokens_mistral': 698, 'n_tokens_neox': 697, 'n_words': 180}