<commit_before>from economic.utils import convert_from_camel_case


class EconomicSerializer(object):
    id_property_name = 'id'

    def __init__(self, auth, object_dict):
        self._mutable_fields = {}
        self._immutable_fields = {}
        self._field_translator = {}
        self.auth = auth
        for field, value in object_dict.items():
            self._field_translator[convert_from_camel_case(field)] = field
            if field in ['self', 'customer']:
                self._immutable_fields[field] = value
            else:
                self._mutable_fields[field] = value

    @property
    def valid_fields(self):
        return [convert_from_camel_case(f) for f in list(self._mutable_fields.keys()) + list(self._immutable_fields.keys())]

    def __repr__(self):
        return "<%s: %s>" % (self.__class__.__name__, self.__str__())

    def __str__(self):
        return self.__unicode__().encode('utf-8')

    def __unicode__(self):
        return u"%d" % getattr(self, self.id_property_name, None)

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self._mutable_fields == other._mutable_fields and \
            self._immutable_fields == other._immutable_fields

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

    def __getattr__(self, item):
        if item not in ['_mutable_fields', '_immutable_fields', '_field_translator', 'auth']:
            key = self._field_translator[item]<commit_msg>serializer now always has an id property<commit_after>from economic.utils import convert_from_camel_case


class EconomicSerializer(object):
    id_property_name = 'id'

    def __init__(self, auth, object_dict):
        self._mutable_fields = {}
        self._immutable_fields = {}
        self._field_translator = {}
        self.auth = auth
        for field, value in object_dict.items():
            self._field_translator[convert_from_camel_case(field)] = field
            if field in ['self', 'customer']:
                self._immutable_fields[field] = value
            else:
                self._mutable_fields[field] = value

    @property
    def valid_fields(self):
        return [convert_from_camel_case(f) for f in list(self._mutable_fields.keys()) + list(self._immutable_fields.keys())]

    def __repr__(self):
        return "<%s: %s>" % (self.__class__.__name__, self.__str__())

    def __str__(self):
        return self.__unicode__().encode('utf-8')

    def __unicode__(self):
        return u"%d" % getattr(self, self.id_property_name, None)

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self._mutable_fields == other._mutable_fields and \
            self._immutable_fields == other._immutable_fields

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

    def __getattr__(self, item):
        if item == 'id':
            return getattr(self, self.id_property_name)
        if item not in ['_mutable_fields', '_immutable_fields', '_field_translator', 'auth']:
            key = self._field_translator[item]
{'fraction_non_alphanumeric': 0.11172638436482085, 'fraction_numerical': 0.0006514657980456026, 'mean_word_length': 2.9021601016518423, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6777252', 'n_tokens_mistral': 913, 'n_tokens_neox': 912, 'n_words': 197}