# Path: muninn/_compat.py
# PY3 = sys.version_info[0] == 3
#     def is_python2_unicode(x):
#     def dictkeys(d):
#     def dictvalues(d):
#     def path_utf8(path):
#     def encode(s):
#     def decode(s):
#     def is_python2_unicode(x):
#     def path_utf8(path):
#     def decode(s):
#     def encode(s):
# 
# Path: muninn/_compat.py
# PY3 = sys.version_info[0] == 3
#     def is_python2_unicode(x):
#     def dictkeys(d):
#     def dictvalues(d):
#     def path_utf8(path):
#     def encode(s):
#     def decode(s):
#     def is_python2_unicode(x):
#     def path_utf8(path):
#     def decode(s):
#     def encode(s):


import datetime
import uuid
import muninn.geometry as geometry
from muninn._compat import long
from muninn._compat import string_types as basestring
        items = {}
        for key, value in dct.items():
            # class: not optional, no index
            if isinstance(value, type) and issubclass(value, Type):
                items[key] = (value, False, False)

            # instance: get optional, index from instance
            elif isinstance(value, Type):
                items[key] = (type(value), value.optional, value.index)

            # optional() wrapper: optional, no index
            elif type(value) is optional:
                items[key] = (value.type, True, False)
            else:
                class_dct[key] = value

        assert "_items" not in class_dct
        class_dct["_items"] = items

        return super(MetaMapping, meta).__new__(meta, name, bases, class_dct)

    def validate(cls, value, partial=False, path=""):
        path = "%s:" % cls.name() if not path else path

        validated = 0
        for sub_name, (sub_type, sub_optional, sub_index) in cls._items.items():
            try:
                sub_value = value[sub_name]
            except TypeError:
                raise ValueError(prefix_message_with_path(path, "expected a mapping"))

# Path: muninn/_compat.py
# PY3 = sys.version_info[0] == 3
#     def is_python2_unicode(x):
#     def dictkeys(d):
#     def dictvalues(d):
#     def path_utf8(path):
#     def encode(s):
#     def decode(s):
#     def is_python2_unicode(x):
#     def path_utf8(path):
#     def decode(s):
#     def encode(s):
# 
# Path: muninn/_compat.py
# PY3 = sys.version_info[0] == 3
#     def is_python2_unicode(x):
#     def dictkeys(d):
#     def dictvalues(d):
#     def path_utf8(path):
#     def encode(s):
#     def decode(s):
#     def is_python2_unicode(x):
#     def path_utf8(path):
#     def decode(s):
#     def encode(s):


# Path: muninn/schema.py
import datetime
import uuid
import muninn.geometry as geometry
from muninn._compat import long
from muninn._compat import string_types as basestring

        items = {}
        for key, value in dct.items():
            # class: not optional, no index
            if isinstance(value, type) and issubclass(value, Type):
                items[key] = (value, False, False)

            # instance: get optional, index from instance
            elif isinstance(value, Type):
                items[key] = (type(value), value.optional, value.index)

            # optional() wrapper: optional, no index
            elif type(value) is optional:
                items[key] = (value.type, True, False)
            else:
                class_dct[key] = value

        assert "_items" not in class_dct
        class_dct["_items"] = items

        return super(MetaMapping, meta).__new__(meta, name, bases, class_dct)

    def validate(cls, value, partial=False, path=""):
        path = "%s:" % cls.name() if not path else path

        validated = 0
        for sub_name, (sub_type, sub_optional, sub_index) in cls._items.items():
            try:
                sub_value = value[sub_name]
            except TypeError:
                raise ValueError(prefix_message_with_path(path, "expected a mapping"))

            except KeyError: