def build_spider_registry(config):
    SPIDER_REGISTRY.clear()

    opt_modules = []
    opt_modules = config['global'].get('spider_modules', [])

    for path in opt_modules:
        if ':' in path:
            path, cls_name = path.split(':')
        else:
            cls_name = None
        try:
            mod = __import__(path, None, None, ['foo'])
        except __HOLE__ as ex:
            if path not in six.text_type(ex):
                logging.error('', exc_info=ex)
        else:
            for key in dir(mod):
                if key == 'Spider':
                    continue
                if cls_name is None or key == cls_name:
                    val = getattr(mod, key)
                    if isinstance(val, type) and issubclass(val, Spider):
                        if val.Meta.abstract:
                            pass
                        else:
                            spider_name = val.get_spider_name()
                            logger.debug(
                                'Module `%s`, found spider `%s` '
                                'with name `%s`' % (
                                    path, val.__name__, spider_name))
                            if spider_name in SPIDER_REGISTRY:
                                mod = SPIDER_REGISTRY[spider_name].__module__
                                raise SpiderInternalError(
                                    'There are two different spiders with '
                                    'the same name "%s". '
                                    'Modules: %s and %s' % (
                                        spider_name, mod, val.__module__))
                            else:
                                SPIDER_REGISTRY[spider_name] = val
    return SPIDER_REGISTRY
dataset/ETHPy150Open lorien/grab/grab/util/module.py/build_spider_registry