<commit_before>from django import forms
from django.contrib.sites.models import Site
from django.core import validators
from django.core.exceptions import ValidationError
from django.template.defaultfilters import filesizeformat as fs_format
from django.utils.translation import ugettext_lazy as _

from utils import DEFAULT_PROTOCOL
from utils.http import url_exists


class MaxFileSizeValidator(object):
    def __init__(self, max_size, message=_(u'Please keep filesize under %(required_size)s. Current filesize %(current_size)s')):
        self.max_size = max_size
        self.message = message

    def __call__(self, content):
        if content._size > self.max_size:
            params = dict(required_size=fs_format(self.max_size), current_size=fs_format(content._size))
            raise ValidationError(self.message % params)


class UniSubURLValidator(validators.URLValidator):
    def __init__(self, verify_exists=False, validator_user_agent=validators.URL_VALIDATOR_USER_AGENT):
        self.host = Site.objects.get_current().domain<commit_msg>2053: updated error message for invalid file size<commit_after>from django import forms
from django.contrib.sites.models import Site
from django.core import validators
from django.core.exceptions import ValidationError
from django.template.defaultfilters import filesizeformat as fs_format
from django.utils.translation import ugettext_lazy as _

from utils import DEFAULT_PROTOCOL
from utils.http import url_exists


class MaxFileSizeValidator(object):
    def __init__(self, max_size, message=_(u'Please keep file size under %(required_size)s. Current file size %(current_size)s')):
        self.max_size = max_size
        self.message = message

    def __call__(self, content):
        if content._size > self.max_size:
            params = dict(required_size=fs_format(self.max_size), current_size=fs_format(content._size))
            raise ValidationError(self.message % params)


class UniSubURLValidator(validators.URLValidator):
    def __init__(self, verify_exists=False, validator_user_agent=validators.URL_VALIDATOR_USER_AGENT):
        self.host = Site.objects.get_current().domain
{'fraction_non_alphanumeric': 0.07567316620241411, 'fraction_numerical': 0.0018570102135561746, 'mean_word_length': 4.920329670329671, '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': '6159005', 'n_tokens_mistral': 610, 'n_tokens_neox': 599, 'n_words': 152}