def build_compilers():
    # noinspection PyShadowingNames
    compilers = {}
    for compiler_path in settings.COMPILERS:
        compiler_options = {}
        if isinstance(compiler_path, (tuple, list)):
            if len(compiler_path) != 2:
                raise django.core.exceptions.ImproperlyConfigured(
                    'Compiler must be specified in the format ("path.to.CompilerClass", {{compiler options...}}),'
                    ' got {0}'.format(compiler_path)
                )
            compiler_path, compiler_options = compiler_path
            if not isinstance(compiler_options, dict):
                raise django.core.exceptions.ImproperlyConfigured(
                    'Compiler options must be a dict, got {0}'.format(compiler_options)
                )

        try:
            compiler_module, compiler_classname = compiler_path.rsplit('.', 1)
        except __HOLE__:
            raise django.core.exceptions.ImproperlyConfigured('{0} isn\'t a compiler module'.format(compiler_path))
        try:
            mod = import_module(compiler_module)
        except ImportError as e:
            raise django.core.exceptions.ImproperlyConfigured(
                'Error importing compiler {0}: "{1}"'.format(compiler_module, e)
            )
        try:
            compiler_class = getattr(mod, compiler_classname)
        except AttributeError:
            raise django.core.exceptions.ImproperlyConfigured(
                'Compiler module "{0}" does not define a "{1}" class'.format(compiler_module, compiler_classname)
            )

        compiler_to_add = compiler_class(**compiler_options)
        compiler = compilers.setdefault(compiler_class.name, compiler_to_add)
        if compiler_to_add != compiler:
            warnings.warn("Both compilers {0} and {1} have the same name.".format(compiler_to_add, compiler))

    return compilers
dataset/ETHPy150Open andreyfedoseev/django-static-precompiler/static_precompiler/utils.py/build_compilers