<commit_before># -*- coding: utf-8 -*-

"""
byceps.blueprints.snippet.service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2015 <NAME>
"""

from flask import g

from .models import Snippet, SnippetVersion


def find_latest_version_of_snippet(name):
    """Return the latest version of the snippet with that name."""
    latest_version = SnippetVersion.query \
        .join(Snippet) \
            .filter(Snippet.party == g.party) \
            .filter(Snippet.name == name) \
        .latest_first() \
        .first()

    if latest_version is None:
        raise SnippetNotFound()

    return latest_version


class SnippetNotFound(Exception):
    pass<commit_msg>Pass snippet name to exception when not found to ease debugging.<commit_after># -*- coding: utf-8 -*-

"""
byceps.blueprints.snippet.service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2015 <NAME>
"""

from flask import g

from .models import Snippet, SnippetVersion


def find_latest_version_of_snippet(name):
    """Return the latest version of the snippet with that name."""
    latest_version = SnippetVersion.query \
        .join(Snippet) \
            .filter(Snippet.party == g.party) \
            .filter(Snippet.name == name) \
        .latest_first() \
        .first()

    if latest_version is None:
        raise SnippetNotFound(name)

    return latest_version


class SnippetNotFound(Exception):

    def __init__(self, name):
        self.name = name
{'fraction_non_alphanumeric': 0.1510344827586207, 'fraction_numerical': 0.012413793103448275, 'mean_word_length': 2.932249322493225, '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': '4219298', 'n_tokens_mistral': 444, 'n_tokens_neox': 414, 'n_words': 109}