<commit_before>import dateutil.parser


class Message(object):

    def __init__(self, data, user=None):
        if isinstance(data, str):
            self.body = data
        else:
            self._data = data
            self.body = data['message']
        if user:
            if data['from'] == user.id:
                self.sender = user
            if data['to'] == user.id:
                self.to = user
            if data['from'] == user._session.profile.id:
                self.sender = user._session.profile
            if data['to'] == user._session.profile.id:
                self.to = user._session.profile
                self.sent = dateutil.parser.parse(data['sent_date'])

    def __repr__(self):
        return self.body

    def __str__(self):
        return self.body
<commit_msg>FIX:  attribute is now always set. REMOVE: isinstance() which allowed Message objects to be built by passing a string instead of a dict (Cannot see a situation where this would be desired)<commit_after>import dateutil.parser


class Message(object):

    def __init__(self, data, user=None):
        self._data = data
        self.sent = dateutil.parser.parse(data['sent_date'])
        self.body = data['message']
        if user:
            if data['from'] == user.id:
                self.sender = user
            if data['to'] == user.id:
                self.to = user
            if data['from'] == user._session.profile.id:
                self.sender = user._session.profile
            if data['to'] == user._session.profile.id:
                self.to = user._session.profile

    def __repr__(self):
        return self.body

    def __str__(self):
        return self.body

{'fraction_non_alphanumeric': 0.11229314420803782, 'fraction_numerical': 0.0, 'mean_word_length': 1.8311036789297659, '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': '5142880', 'n_tokens_mistral': 471, 'n_tokens_neox': 452, 'n_words': 126}