<commit_before>from django.conf import settings
from django.conf.urls import url, include, patterns
from django.utils.module_loading import import_string

from rest_framework import routers
from rest_framework_swagger.views import get_swagger_view

from .images import views as images_views
from .pages import views as pages_views


schema_doc_view = get_swagger_view(title='GLAMkit API')

# Obtain the default router and register local APIs
router = routers.DefaultRouter()
router.register(r'images', images_views.ImageViewSet, 'images-api')
router.register(r'pages', pages_views.PageViewSet, 'pages-api')

# Register pluggable API routers defined elsewhere
for api_section_name, pluggable_router \
        in getattr(settings, 'EXTRA_API_ROUTERS', []):
    if isinstance(pluggable_router, basestring):
        pluggable_router = import_string(pluggable_router)
    for prefix, viewset, basename in pluggable_router.registry:
        if api_section_name:
            prefix = api_section_name + prefix
        router.register(prefix, viewset, basename)
<commit_msg>#213 Log errors don't fail when loading extra API routers<commit_after>import logging

from django.conf import settings
from django.conf.urls import url, include
from django.utils.module_loading import import_string

from rest_framework import routers
from rest_framework_swagger.views import get_swagger_view

from .images import views as images_views
from .pages import views as pages_views

logger = logging.getLogger(__name__)


schema_doc_view = get_swagger_view(title='GLAMkit API')

# Obtain the default router and register local APIs
router = routers.DefaultRouter()
router.register(r'images', images_views.ImageViewSet, 'images-api')
router.register(r'pages', pages_views.PageViewSet, 'pages-api')

# Register pluggable API routers defined elsewhere
for api_section_name, pluggable_router \
        in getattr(settings, 'EXTRA_API_ROUTERS', []):
    if isinstance(pluggable_router, basestring):
        try:
            pluggable_router = import_string(pluggable_router)
        except ImportError, ex:
            logger.warn(
                "Failed to load API router '%s' from EXTRA_API_ROUTERS: %s"
                % (pluggable_router, ex))
            continue
    for prefix, viewset, basename in pluggable_router.registry:
        if api_section_name:
            prefix = api_section_name + prefix
        router.register(prefix, viewset, basename)

{'fraction_non_alphanumeric': 0.07233867653103165, 'fraction_numerical': 0.0012330456226880395, 'mean_word_length': 4.408888888888889, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2596167', 'n_tokens_mistral': 706, 'n_tokens_neox': 701, 'n_words': 197}