<commit_before>"""
byceps.util.framework.blueprint
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Blueprint utilities

:Copyright: 2006-2021 <NAME>
:License: Revised BSD (see `LICENSE` file for details)
"""

from importlib import import_module

from flask import Blueprint


def create_blueprint(name, import_name):
    """Create a blueprint with default folder names."""
    return Blueprint(
        name, import_name, static_folder='static', template_folder='templates'
    )


def register_blueprint(app, name, url_prefix):
    """Register a blueprint with the application.

    The module with the given name is expected to be located inside the
    'blueprints' sub-package and to contain a blueprint instance named
    'blueprint'.
    """
    module = _get_blueprint_views_module(name)
    blueprint = getattr(module, 'blueprint')
    app.register_blueprint(blueprint, url_prefix=url_prefix)


def _get_blueprint_views_module(name):
    """Import and return the 'views' module located in the specified
    blueprint package.
    """
    return import_module(f'byceps.blueprints.{name}.views')<commit_msg>Add type hints to blueprint utilities module<commit_after>"""
byceps.util.framework.blueprint
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Blueprint utilities

:Copyright: 2006-2021 <NAME>
:License: Revised BSD (see `LICENSE` file for details)
"""

from importlib import import_module
from types import ModuleType

from flask import Blueprint, Flask


def create_blueprint(name: str, import_name: str) -> Blueprint:
    """Create a blueprint with default folder names."""
    return Blueprint(
        name, import_name, static_folder='static', template_folder='templates'
    )


def register_blueprint(app: Flask, name: str, url_prefix: str) -> None:
    """Register a blueprint with the application.

    The module with the given name is expected to be located inside the
    'blueprints' sub-package and to contain a blueprint instance named
    'blueprint'.
    """
    module = _get_blueprint_views_module(name)
    blueprint = getattr(module, 'blueprint')
    app.register_blueprint(blueprint, url_prefix=url_prefix)


def _get_blueprint_views_module(name: str) -> ModuleType:
    """Import and return the 'views' module located in the specified
    blueprint package.
    """
    return import_module(f'byceps.blueprints.{name}.views')
{'fraction_non_alphanumeric': 0.11630901287553648, 'fraction_numerical': 0.0068669527896995704, 'mean_word_length': 4.6440677966101696, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, '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': '227734', 'n_tokens_mistral': 689, 'n_tokens_neox': 656, 'n_words': 209}