def data2schemacls(_data, **kwargs):
    """Convert a data to a schema cls.

    :param data: object or dictionary from where get a schema cls.
    :return: schema class.
    :rtype: type
    """
    content = {}

    for key in list(kwargs):  # fill kwargs
        kwargs[key] = data2schema(kwargs[key])

    if isinstance(_data, dict):
        datacontent = iteritems(_data)

    else:
        datacontent = getmembers(_data)

    for name, value in datacontent:

        if name[0] == '_':
            continue

        if isinstance(value, dict):
            schema = data2schemacls(value)()

        else:
            schema = data2schema(value)

        content[name] = schema

    content.update(kwargs)  # update content

    result = type('GeneratedSchema', (Schema,), content)

    return result
def data2schemacls ( _data , ** kwargs ) : content = { } for key in list ( kwargs ) : kwargs [ key ] = data2schema ( kwargs [ key ] ) if isinstance ( _data , dict ) : datacontent = iteritems ( _data ) else : datacontent = getmembers ( _data ) for name , value in datacontent : if name [ 0 ] == '_' : continue if isinstance ( value , dict ) : schema = data2schemacls ( value ) ( ) else : schema = data2schema ( value ) content [ name ] = schema content . update ( kwargs ) result = type ( 'GeneratedSchema' , ( Schema , ) , content ) return result
Convert a data to a schema cls.

    :param data: object or dictionary from where get a schema cls.
    :return: schema class.
    :rtype: type