<commit_before>"""
byceps.blueprints.snippet.init
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 <NAME>
:License: Modified BSD, see LICENSE for details.
"""

from flask import current_app

from ...services.snippet import mountpoint_service

from .views import blueprint as snippet_blueprint, view_current_version_by_name


def add_routes_for_snippets(site_id):
    """Register routes for snippets with the application."""
    mountpoints = mountpoint_service.get_mountpoints_for_site(site_id)

    for mountpoint in mountpoints:
        add_route_for_snippet(mountpoint)


def add_route_for_snippet(mountpoint):
    """Register a route for the snippet."""
    endpoint = '{}.{}'.format(snippet_blueprint.name,
                              mountpoint.endpoint_suffix)
    defaults = {'name': mountpoint.snippet.name}

    current_app.add_url_rule(
        mountpoint.url_path,
        endpoint,
        view_func=view_current_version_by_name,
        defaults=defaults)
<commit_msg>Fix snippet URL rules to use mountpoints' endpoint suffix<commit_after>"""
byceps.blueprints.snippet.init
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2019 <NAME>
:License: Modified BSD, see LICENSE for details.
"""

from flask import current_app

from ...services.snippet import mountpoint_service

from .views import blueprint as snippet_blueprint, view_current_version_by_name


def add_routes_for_snippets(site_id):
    """Register routes for snippets with the application."""
    mountpoints = mountpoint_service.get_mountpoints_for_site(site_id)

    for mountpoint in mountpoints:
        add_route_for_snippet(mountpoint)


def add_route_for_snippet(mountpoint):
    """Register a route for the snippet."""
    endpoint = '{}.{}'.format(snippet_blueprint.name,
                              mountpoint.endpoint_suffix)
    defaults = {'name': mountpoint.endpoint_suffix}

    current_app.add_url_rule(
        mountpoint.url_path,
        endpoint,
        view_func=view_current_version_by_name,
        defaults=defaults)

{'fraction_non_alphanumeric': 0.11358024691358025, 'fraction_numerical': 0.007901234567901235, 'mean_word_length': 4.065, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1862349', 'n_tokens_mistral': 620, 'n_tokens_neox': 581, 'n_words': 132}