<commit_before>"""Models for the database of ahmia."""
from django.core.validators import MaxLengthValidator, MinLengthValidator
from django.db import models

from search.views.helpers import validate_onion_url

class HiddenWebsite(models.Model):
    """Hidden service website."""
    #for instance: http://3g2upl4pq6kufc4m.onion/
    url = models.URLField(validators=[validate_onion_url], unique=True)<commit_msg>Fix cycling import<commit_after>"""Models for the database of ahmia."""
from django.core.exceptions import ValidationError
from django.core.validators import MaxLengthValidator, MinLengthValidator
from django.db import models

def validate_onion_url(url):
    """ Test is url correct onion URL."""
    #Must be like http://3g2upl4pq6kufc4m.onion/
    if len(url) != 30:
        raise ValidationError(u'%s length is not 30' % url)
    if url[0:7] != 'http://':
        raise ValidationError(u'%s is not beginning with http://' % url)
    if url[-7:] != '.onion/':
        raise ValidationError(u'%s is not ending with .onion/' % url)
    if not re.match("[a-z2-7]{16}", url[7:-7]):
        raise ValidationError(u'%s is not valid onion domain' % url)

class HiddenWebsite(models.Model):
    """Hidden service website."""
    #for instance: http://3g2upl4pq6kufc4m.onion/
    url = models.URLField(validators=[validate_onion_url], unique=True)
{'fraction_non_alphanumeric': 0.12915129151291513, 'fraction_numerical': 0.020664206642066422, 'mean_word_length': 4.317647058823529, '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': '316752', 'n_tokens_mistral': 448, 'n_tokens_neox': 426, 'n_words': 117}