<commit_before>import python_jsonschema_objects.util as util
import python_jsonschema_objects.validators as validators

import collections
import itertools
import six

import logging
logger = logging.getLogger(__name__)


class ProtocolBase( collections.MutableMapping):
    __propinfo__ = {}
    __required__ = set()

    __SCHEMA_TYPES__ = {
        'array': list,
        'boolean': bool,
        'integer': int,
        'number': (float, int),
        'null': None,
        'string': six.string_types,
        'object': dict
    }

    def as_dict(self):
        out = {}
        for prop in self:
            propval = getattr(self, prop)

            if isinstance(propval, list):
                out[prop] = [x.as_dict() for x in propval]
            elif not isinstance(propval, LiteralValue) and propval is not None:
                out[prop] = propval
            elif propval is not None:
                out[prop] = propval.as_dict()

        return out

    def __str__(self):
        return repr(self)

    def __repr__(self):
        inverter = dict((v, k) for k,v in six.iteritems(self.__prop_names__))
        props = ["%s=%s" % (inverter[k], str(v)) for k, v in
                 itertools.chain(six.iteritems(self._properties),<commit_msg>Tweak protocol mapping to include 'long' types as well, and ensure compatibility with python3.<commit_after>import python_jsonschema_objects.util as util
import python_jsonschema_objects.validators as validators

import collections
import itertools
import six
import sys

import logging
logger = logging.getLogger(__name__)

# Long is no longer a thing in python3.x
if sys.version_info > (3,):
  long = int

class ProtocolBase( collections.MutableMapping):
    __propinfo__ = {}
    __required__ = set()

    __SCHEMA_TYPES__ = {
        'array': list,
        'boolean': bool,
        'integer': int,
        'number': (float, int, long),
        'null': None,
        'string': six.string_types,
        'object': dict
    }

    def as_dict(self):
        out = {}
        for prop in self:
            propval = getattr(self, prop)

            if isinstance(propval, list):
                out[prop] = [x.as_dict() for x in propval]
            elif not isinstance(propval, LiteralValue) and propval is not None:
                out[prop] = propval
            elif propval is not None:
                out[prop] = propval.as_dict()

        return out

    def __str__(self):
        return repr(self)

    def __repr__(self):
        inverter = dict((v, k) for k,v in six.iteritems(self.__prop_names__))
        props = ["%s=%s" % (inverter[k], str(v)) for k, v in
                 itertools.chain(six.iteritems(self._properties),
{'fraction_non_alphanumeric': 0.10319227913882702, 'fraction_numerical': 0.0011135857461024498, 'mean_word_length': 2.351990049751244, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4428674', 'n_tokens_mistral': 818, 'n_tokens_neox': 806, 'n_words': 230}