<commit_before>import json

from marathon.util import to_camel_case, to_snake_case, MarathonJsonEncoder


class MarathonObject(object):
    """Base Marathon object."""

    def json_repr(self):
        """Construct a JSON-friendly representation of the object.

        :rtype: dict
        """
        return {to_camel_case(k):v for k,v in vars(self).iteritems()}

    @classmethod
    def from_json(cls, attributes):
        """Construct an object from a parsed response.

        :param dict attributes: object attributes from parsed response
        """
        return cls(**{to_snake_case(k): v for k,v in attributes.iteritems()})


class MarathonResource(MarathonObject):
    """Base Marathon resource."""

    def __repr__(self):
        if 'id' in vars(self).keys():
            return "{clazz}::{id}".format(clazz=self.__class__.__name__, id=self.id)
        else:
            return "{clazz}::{obj}".format(clazz=self.__class__.__name__, obj=self.to_json())

    def to_json(self):
        """Encode an object as a JSON string.

        :rtype: str
        """
        return json.dumps(self.json_repr(), cls=MarathonJsonEncoder, sort_keys=True)<commit_msg>Tweak Marathon object __repr__<commit_after>import json

from marathon.util import to_camel_case, to_snake_case, MarathonJsonEncoder


class MarathonObject(object):
    """Base Marathon object."""

    def __repr__(self):
        return "{clazz}::{obj}".format(clazz=self.__class__.__name__, obj=self.to_json())

    def json_repr(self):
        """Construct a JSON-friendly representation of the object.

        :rtype: dict
        """
        return {to_camel_case(k):v for k,v in vars(self).iteritems()}

    @classmethod
    def from_json(cls, attributes):
        """Construct an object from a parsed response.

        :param dict attributes: object attributes from parsed response
        """
        return cls(**{to_snake_case(k): v for k,v in attributes.iteritems()})

    def to_json(self):
        """Encode an object as a JSON string.

        :rtype: str
        """
        return json.dumps(self.json_repr(), cls=MarathonJsonEncoder, sort_keys=True)


class MarathonResource(MarathonObject):
    """Base Marathon resource."""

    def __repr__(self):
        if 'id' in vars(self).keys():
            return "{clazz}::{id}".format(clazz=self.__class__.__name__, id=self.id)
        else:
            return super(MarathonResource).__repr__()

{'fraction_non_alphanumeric': 0.12443345694272764, 'fraction_numerical': 0.0, 'mean_word_length': 3.067001675041876, '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': '4496603', 'n_tokens_mistral': 742, 'n_tokens_neox': 716, 'n_words': 184}