<commit_before># -*- coding: utf-8 -*-
import os.path
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.db.models.signals import pre_delete
from django.dispatch.dispatcher import receiver
from django.utils.encoding import python_2_unicode_compatible
from django.utils.six import text_type
from django.core.urlresolvers import reverse
from django.core.exceptions import SuspiciousFileOperation
from waliki.models import Page
from waliki.settings import WALIKI_UPLOAD_TO


@python_2_unicode_compatible
class Attachment(models.Model):
    page = models.ForeignKey(Page, related_name='attachments')
    file = models.FileField(upload_to=WALIKI_UPLOAD_TO)

    class Meta:
        verbose_name = _("Attachment")
        verbose_name_plural = _("Attachments")

    def __str__(self):
    	return os.path.basename(self.file.name)

    def get_absolute_url(self):
        return reverse('waliki_attachment_file', args=(self.page.slug, self.id, text_type(self)))


# @receiver(pre_delete, sender=Attachment)
# def attachment_delete(sender, instance, **kwargs):
#    try:
#        # instance.file.delete(False)
#        pass
#    except SuspiciousFileOperation:
#        pass<commit_msg>removing unused import<commit_after># -*- coding: utf-8 -*-
import os.path
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.db.models.signals import pre_delete
from django.dispatch.dispatcher import receiver
from django.utils.encoding import python_2_unicode_compatible
from django.utils.six import text_type
from django.core.urlresolvers import reverse
from waliki.models import Page
from waliki.settings import WALIKI_UPLOAD_TO


@python_2_unicode_compatible
class Attachment(models.Model):
    page = models.ForeignKey(Page, related_name='attachments')
    file = models.FileField(upload_to=WALIKI_UPLOAD_TO)

    class Meta:
        verbose_name = _("Attachment")
        verbose_name_plural = _("Attachments")

    def __str__(self):
    	return os.path.basename(self.file.name)

    def get_absolute_url(self):
        return reverse('waliki_attachment_file', args=(self.page.slug, self.id, text_type(self)))


# @receiver(pre_delete, sender=Attachment)
# def attachment_delete(sender, instance, **kwargs):
#    try:
#        # instance.file.delete(False)
#        pass
#    except SuspiciousFileOperation:
#        pass
{'fraction_non_alphanumeric': 0.09341117597998332, 'fraction_numerical': 0.0025020850708924102, 'mean_word_length': 4.592074592074592, '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': '7530757', 'n_tokens_mistral': 740, 'n_tokens_neox': 731, 'n_words': 163}