<commit_before>import importlib
import inspect
import json
import logging
import os
import os.path
import pkgutil
from typing import List, Dict

import cherrypy
from simple_settings import settings

from ingredients_http.router import Router


class ApplicationMount(object):
    def __init__(self, app, mount_point: str, routers_location: str = 'routes'):
        self.logger = logging.getLogger("%s.%s" % (self.__module__, self.__class__.__name__))
        self.app = app
        self.mount_point = mount_point
        self._dispatcher = cherrypy.dispatch.RoutesDispatcher()
        self.routers_location = routers_location

    def __import_routers(self, package) -> List[Router]:
        routers = []
        for _, name, is_pkg in pkgutil.walk_packages(package.__path__):
            full_name = package.__name__ + '.' + name
            module = importlib.import_module(full_name)
            if is_pkg:
                routers.extend(self.__import_routers(importlib.import_module(full_name)))
            else:
                for name, obj in inspect.getmembers(module):
                    if inspect.isclass(obj) and issubclass(obj, Router) and obj is not Router:
                        self.logger.debug("Found Router Object: " + obj.__name__)
                        router = obj()
                        routers.append(router)

        return routers
<commit_msg>ignore routers that have a metaclass<commit_after>import importlib
import inspect
import json
import logging
import os
import os.path
import pkgutil
from typing import List, Dict

import cherrypy
from simple_settings import settings

from ingredients_http.router import Router


class ApplicationMount(object):
    def __init__(self, app, mount_point: str, routers_location: str = 'routes'):
        self.logger = logging.getLogger("%s.%s" % (self.__module__, self.__class__.__name__))
        self.app = app
        self.mount_point = mount_point
        self._dispatcher = cherrypy.dispatch.RoutesDispatcher()
        self.routers_location = routers_location

    def __import_routers(self, package) -> List[Router]:
        routers = []
        for _, name, is_pkg in pkgutil.walk_packages(package.__path__):
            full_name = package.__name__ + '.' + name
            module = importlib.import_module(full_name)
            if is_pkg:
                routers.extend(self.__import_routers(importlib.import_module(full_name)))
            else:
                for name, obj in inspect.getmembers(module):
                    if inspect.isclass(obj) and issubclass(obj, Router) and obj is not Router:
                        if obj.__dict__.get('__metaclass__') is not None:
                            continue
                        self.logger.debug("Found Router Object: " + obj.__name__)
                        router = obj()
                        routers.append(router)

        return routers

{'fraction_non_alphanumeric': 0.08269896193771627, 'fraction_numerical': 0.0, 'mean_word_length': 2.4011764705882355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6485575', 'n_tokens_mistral': 795, 'n_tokens_neox': 765, 'n_words': 199}