<commit_before>#    Copyright (c) 2014 Rackspace
#    Copyright (c) 2016 Blue Box, an IBM Company
#    All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import re

from sqlalchemy.orm import collections

from octavia.common import constants


class BaseDataModel(object):

    # NOTE(brandon-logan) This does not discover dicts for relationship
    # attributes.
    def to_dict(self):
        """Converts a data model to a dictionary."""
        ret = {}
        for attr in self.__dict__:
            if attr.startswith('_'):
                continue
            if isinstance(getattr(self, attr), (BaseDataModel, list)):
                ret[attr] = None
            else:
                ret[attr] = self.__dict__[attr]
        return ret

    def __eq__(self, other):
        if isinstance(other, self.__class__):
            return self.to_dict() == other.to_dict()
        return False

    @classmethod<commit_msg>Add __ne__ built-in function<commit_after>#    Copyright (c) 2014 Rackspace
#    Copyright (c) 2016 Blue Box, an IBM Company
#    All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import re

from sqlalchemy.orm import collections

from octavia.common import constants


class BaseDataModel(object):

    # NOTE(brandon-logan) This does not discover dicts for relationship
    # attributes.
    def to_dict(self):
        """Converts a data model to a dictionary."""
        ret = {}
        for attr in self.__dict__:
            if attr.startswith('_'):
                continue
            if isinstance(getattr(self, attr), (BaseDataModel, list)):
                ret[attr] = None
            else:
                ret[attr] = self.__dict__[attr]
        return ret

    def __eq__(self, other):
        if isinstance(other, self.__class__):
            return self.to_dict() == other.to_dict()
        return False

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

    @classmethod
{'fraction_non_alphanumeric': 0.08087504143188598, 'fraction_numerical': 0.007954922108054359, 'mean_word_length': 2.54641598119859, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3195488', 'n_tokens_mistral': 823, 'n_tokens_neox': 793, 'n_words': 320}