0
  $   ˆÇ’þDVl²„,�7  ´ÞÍ_óÍÊÉÌ303Æ¿Ï /    ‹      •�1oÂ0…gü+µÈŽTâŠ��ˆ¡CÕ¢ÉÐ?`Â®;=;¥QÅ¯	‚‘õÞ»ïÝ=Þ:çI—žgŒý(‚7ô+&Æé–@øÝjBÁwè§zxÒ»?»_‰,ïõªà“‹4¹ØW® Û ùî»kz*o¤¸ýqk‹“NJØ{ß¸…”XÖ*Þ†d”×Ö¨*µ´;�gó™œ§ÏòÁa9µ´ÑFQ·W®éÃ«í¦­0ÅßÆ’w!mÛš2b ïíïêr›ÈŸ Hà��ôD<Fä	Œ—KàùúC�'qä÷d`ðpÕ�à/ÎHDo•®p³€� ëa`dlt<GŒozEr¿€ºuÖ
ôÇBß’	6ÞÍØ1cÿ5¶Þ6    !   ˆÎ�þZt‘¬Ü qº)üÿÍ„ÌºÿÌË¿Ï ?÷     from __future__ import absolute_import

from warnings import warn

from pipenv.vendor.cerberus import errors
from pipenv.vendor.cerberus.platform import (
    _str_type,
    Callable,
    Hashable,
    Mapping,
    MutableMapping,
    Sequence,
)
from pipenv.vendor.cerberus.utils import (
    get_Validator_class,
    validator_factory,
    mapping_hash,
    TypeDefinition,
)


class _Abort(Exception):
    pass


class SchemaError(Exception):
    """
    Raised when the validation schema is missing, has the wrong format or contains
    errors."""

    pass


class DefinitionSchema(MutableMapping):
    """A dict-subclass for caching of validated schemas."""

    def __new__(cls, *args, **kwargs):
        if 'SchemaValidator' not in globals():
            global SchemaValidator
            SchemaValidator = validator_factory('SchemaValidator', SchemaValidatorMixin)
            types_mapping = SchemaValidator.types_mapping.copy()
            types_mapping.update(
                {
                    'callable': TypeDefinition('callable', (Callable,), ()),
                    'hashable': TypeDefinition('hashable', (Hashable,), ()),
                }
            )
            SchemaValidator.types_mapping = types_mapping

        return super(DefinitionSchema, cls).__new__(cls)

    def __init__(self, validator, schema):
        """
        :param validator: An instance of Validator-(sub-)class that uses this
                          schema.
        :param schema: A definition-schema as ``dict``. Defaults to an empty
                       one.
        """
        if not isinstance(validator, get_Validator_class()):
            raise RuntimeError('validator argument must be a Validator-' 'instance.')
        self.validator = validator

        if isinstance(schema, _str_type):
            schema = validator.schema_registry.get(schema, schema)

        if not isinstance(schema, Mapping):
            try:
                schema = dict(schema)
            except Exception:
                raise SchemaError(errors.SCHEMA_ERROR_DEFINITION_TYPE.format(schema))

        self.validation_schema = SchemaValidationSchema(validator)
        self.schema_validator = SchemaValidator(
            None,
            allow_unknown=self.validation_schema,
            error_handler=errors.SchemaErrorHandler,
            target_schema=schema,
            target_validator=validator,
        )

        schema = self.expand(schema)
        self.validate(schema)
        self.schema = schema

    def __delitem__(self, key):
        _new_schema = self.schema.copy()
        try:
            del _new_schema[key]
        except ValueError:
            raise SchemaError("Schema has no field '%s' defined" % key)
        except Exception as e:
            raise e
        else:
            del self.schema[key]

    def __getitem__(self, item):
        return self.schema[item]

    def __iter__(self):
        return iter(self.schema)

    def __len__(self):
        return len(self.schema)

    def __repr__(self):
        return str(self)

    def __setitem__(self, key, value):
        value = self.expand({0: value})[0]
        self.validate({key: value})
        self.schema[key] = value

    def __str__(self):
        if hasattr(self, "schema"):
            return str(self.schema)
        else:
            return "No schema data is set yet."

    def copy(self):
        return self.__class__(self.validator, self.schema.copy())

    @classmethod
    def expand(cls, schema):
        try:
            schema = cls._expand_logical_shortcuts(schema)
            schema = cls._expand_subschemas(schema)
        except Exception:
            pass

        # TODO remov