<commit_before>import urlparse

from django.http import QueryDict
from django.utils.crypto import get_random_string, salted_hmac
from django.utils.encoding import force_bytes

from model_settings.models import Text


class PublishingException(Exception):
    pass


class NotDraftException(PublishingException):
    pass


def assert_draft(method):
    def decorated(self, *args, **kwargs):
        if not self.is_draft:
            raise NotDraftException()

        return method(self, *args, **kwargs)
    return decorated
<commit_msg>Add utility method `get_publishable_models()`, re #5 #23<commit_after>import urlparse

from django.apps import apps
from django.http import QueryDict
from django.utils.crypto import get_random_string, salted_hmac
from django.utils.encoding import force_bytes

from model_settings.models import Text


class PublishingException(Exception):
    pass


class NotDraftException(PublishingException):
    pass


def get_publishable_models():
    from .models import PublishingModel
    publishable_models = [
        model for model in apps.get_models()
        if issubclass(model, PublishingModel)
    ]
    return publishable_models


def assert_draft(method):
    def decorated(self, *args, **kwargs):
        if not self.is_draft:
            raise NotDraftException()

        return method(self, *args, **kwargs)
    return decorated

{'fraction_non_alphanumeric': 0.07059679767103348, 'fraction_numerical': 0.002183406113537118, 'mean_word_length': 4.055147058823529, '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': '3070722', 'n_tokens_mistral': 384, 'n_tokens_neox': 371, 'n_words': 111}