<commit_before>import codecs
import copy
import json
import logging
import os.path
import warnings

import inflection
import jsonschema
import six
from jsonschema import Draft4Validator
from jsonschema.compat import iteritems

import python_jsonschema_objects.classbuilder as classbuilder
import python_jsonschema_objects.markdown_support
import python_jsonschema_objects.util
from python_jsonschema_objects.validators import ValidationError


logger = logging.getLogger(__name__)

__all__ = ["ObjectBuilder", "markdown_support", "ValidationError"]

FILE = __file__

SUPPORTED_VERSIONS = (
    "http://json-schema.org/draft-03/schema#",
    "http://json-schema.org/draft-04/schema#",
)


class ObjectBuilder(object):
    def __init__(self, schema_uri, resolved={}, resolver=None, validatorClass=None):
        self.mem_resolved = resolved

        if isinstance(schema_uri, six.string_types):
            uri = os.path.normpath(schema_uri)
            self.basedir = os.path.dirname(uri)
            with codecs.open(uri, "r", "utf-8") as fin:
                self.schema = json.loads(fin.read())
        else:
            self.schema = schema_uri
            uri = os.path.normpath(FILE)
            self.basedir = os.path.dirname(uri)

        if (
            "$schema" in self.schema
            and self.schema["$schema"] not in SUPPORTED_VERSIONS
        ):
            warnings.warn(
                "Schema version {} not recognized. Some "
                "keywords and features may not be supported.".format(
                    self.schema["$schema"]
                )
            )

        self.resolver = resolver or jsonschema.RefResolver.from_schema(self.schema)
        self.resolver.handlers.update(
            {"file": self.relative_file_resolver, "memory": self.memory_resolver}
        )

        validatorClass = validatorClass or Draft4Validator
        meta_validator = validatorClass(Draft4Validator.META_SCHEMA)
        meta_validator.validate(self.schema)
        self.validator = validatorClass(self.schema, resolver=self.resolver)

        self._classes = None
        self._resolved = None

    @property
    def schema(self):
        try:
            return copy.deepcopy(self._schema)<commit_msg>#203 use the passed validatorClasses META_SCHEMA<commit_after>import codecs
import copy
import json
import logging
import os.path
import warnings

import inflection
import jsonschema
import six
from jsonschema import Draft4Validator
from jsonschema.compat import iteritems

import python_jsonschema_objects.classbuilder as classbuilder
import python_jsonschema_objects.markdown_support
import python_jsonschema_objects.util
from python_jsonschema_objects.validators import ValidationError


logger = logging.getLogger(__name__)

__all__ = ["ObjectBuilder", "markdown_support", "ValidationError"]

FILE = __file__

SUPPORTED_VERSIONS = (
    "http://json-schema.org/draft-03/schema#",
    "http://json-schema.org/draft-04/schema#",
)


class ObjectBuilder(object):
    def __init__(self, schema_uri, resolved={}, resolver=None, validatorClass=None):
        self.mem_resolved = resolved

        if isinstance(schema_uri, six.string_types):
            uri = os.path.normpath(schema_uri)
            self.basedir = os.path.dirname(uri)
            with codecs.open(uri, "r", "utf-8") as fin:
                self.schema = json.loads(fin.read())
        else:
            self.schema = schema_uri
            uri = os.path.normpath(FILE)
            self.basedir = os.path.dirname(uri)

        if (
            "$schema" in self.schema
            and self.schema["$schema"] not in SUPPORTED_VERSIONS
        ):
            warnings.warn(
                "Schema version {} not recognized. Some "
                "keywords and features may not be supported.".format(
                    self.schema["$schema"]
                )
            )

        self.resolver = resolver or jsonschema.RefResolver.from_schema(self.schema)
        self.resolver.handlers.update(
            {"file": self.relative_file_resolver, "memory": self.memory_resolver}
        )

        validatorClass = validatorClass or Draft4Validator
        meta_validator = validatorClass(validatorClass.META_SCHEMA)
        meta_validator.validate(self.schema)
        self.validator = validatorClass(self.schema, resolver=self.resolver)

        self._classes = None
        self._resolved = None

    @property
    def schema(self):
        try:
            return copy.deepcopy(self._schema)
{'fraction_non_alphanumeric': 0.09105075690115762, 'fraction_numerical': 0.004007123775601068, 'mean_word_length': 2.6888341543513956, 'pattern_counts': {'":': 4, '<': 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': '4424670', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1273, 'n_words': 270}