# Path: django_make_app/exceptions.py
# class SchemaError(Exception):
#     pass
# 
# Path: django_make_app/utils.py
# def is_callable(obj):
#     return hasattr(obj, '__call__')


import re
from django_make_app.exceptions import SchemaError
from django_make_app.utils import is_callable

def normalize_single_field(field):
    """
    :type field: unicode
    :rtype: dict
    """
    field_name, field_type = field.split(":")

    if not field_type or field_type not in MAPPINGS:
        raise SchemaError("Type {} is invalid".format(field_type))

    field_class = MAPPINGS.get(field_type)

    return {
        "name": field_name,
        "class": field_class(field_name) if is_callable(field_class) else field_class
    }


def normalize_fields(fields):
    """
    :type fields: list of unicode
    :rtype: dict
    """
    for field in fields:
        yield normalize_single_field(field)


def validate_model_name(model_name):
    if not re.search(MODEL_NAME_RE, model_name):

# Path: django_make_app/exceptions.py
# class SchemaError(Exception):
#     pass
# 
# Path: django_make_app/utils.py
# def is_callable(obj):
#     return hasattr(obj, '__call__')


# Path: django_make_app/schema.py
import re
from django_make_app.exceptions import SchemaError
from django_make_app.utils import is_callable


def normalize_single_field(field):
    """
    :type field: unicode
    :rtype: dict
    """
    field_name, field_type = field.split(":")

    if not field_type or field_type not in MAPPINGS:
        raise SchemaError("Type {} is invalid".format(field_type))

    field_class = MAPPINGS.get(field_type)

    return {
        "name": field_name,
        "class": field_class(field_name) if is_callable(field_class) else field_class
    }


def normalize_fields(fields):
    """
    :type fields: list of unicode
    :rtype: dict
    """
    for field in fields:
        yield normalize_single_field(field)


def validate_model_name(model_name):
    if not re.search(MODEL_NAME_RE, model_name):

        raise SchemaError("\"{}\" is not a valid name of Django model.".format(model_name))