# Path: elasticsearch_dsl/exceptions.py
# class UnknownDslObject(ElasticsearchDslException):
#     pass
# 
# class ValidationException(ValueError, ElasticsearchDslException):
#     pass


    import collections.abc as collections_abc  # only works on python 3.3+
    import collections as collections_abc
from copy import copy
from six import add_metaclass, iteritems
from six.moves import map
from .exceptions import UnknownDslObject, ValidationException

    It then uses the information from that registry (as well as `name` and
    `shortcut` attributes from the base class) to construct any subclass based
    on it's name.

    For typical use see `QueryMeta` and `Query` in `elasticsearch_dsl.query`.
    """

    _types = {}

    def __init__(cls, name, bases, attrs):
        super(DslMeta, cls).__init__(name, bases, attrs)
        # skip for DslBase
        if not hasattr(cls, "_type_shortcut"):
            return
        if cls.name is None:
            # abstract base class, register it's shortcut
            cls._types[cls._type_name] = cls._type_shortcut
            # and create a registry for subclasses
            if not hasattr(cls, "_classes"):
                cls._classes = {}
        elif cls.name not in cls._classes:
            # normal class, register it
            cls._classes[cls.name] = cls

    @classmethod
    def get_dsl_type(cls, name):
        try:
            return cls._types[name]
        except KeyError:

# Path: elasticsearch_dsl/exceptions.py
# class UnknownDslObject(ElasticsearchDslException):
#     pass
# 
# class ValidationException(ValueError, ElasticsearchDslException):
#     pass


# Path: elasticsearch_dsl/utils.py
    import collections.abc as collections_abc  # only works on python 3.3+
    import collections as collections_abc
from copy import copy
from six import add_metaclass, iteritems
from six.moves import map
from .exceptions import UnknownDslObject, ValidationException


    It then uses the information from that registry (as well as `name` and
    `shortcut` attributes from the base class) to construct any subclass based
    on it's name.

    For typical use see `QueryMeta` and `Query` in `elasticsearch_dsl.query`.
    """

    _types = {}

    def __init__(cls, name, bases, attrs):
        super(DslMeta, cls).__init__(name, bases, attrs)
        # skip for DslBase
        if not hasattr(cls, "_type_shortcut"):
            return
        if cls.name is None:
            # abstract base class, register it's shortcut
            cls._types[cls._type_name] = cls._type_shortcut
            # and create a registry for subclasses
            if not hasattr(cls, "_classes"):
                cls._classes = {}
        elif cls.name not in cls._classes:
            # normal class, register it
            cls._classes[cls.name] = cls

    @classmethod
    def get_dsl_type(cls, name):
        try:
            return cls._types[name]
        except KeyError:

            raise UnknownDslObject("DSL type %s does not exist." % name)