<commit_before># -*- coding: utf-8 -*-
import uuid
import os
from datetime import datetime

from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone

from taggit.managers import TaggableManager

from opps.core.models import Publishable


def get_file_path(instance, filename):
    ext = filename.split('.')[-1]
    filename = "{0}-{1}.{2}".format(uuid.uuid4(), instance.slug, ext)
    d = datetime.now()
    folder = "images/{0}".format(d.strftime("%Y/%m/%d/"))
    return os.path.join(folder, filename)


class Image(Publishable):

    title = models.CharField(_(u"Title"), max_length=140, db_index=True)
    slug = models.SlugField(_(u"Slug"), max_length=150, blank=True,
                            db_index=True)
    image = models.ImageField(upload_to=get_file_path)
    description = models.TextField(_(u"Description"), null=True, blank=True)
    tags = TaggableManager(blank=True)

    source = models.ForeignKey('sources.Source', null=True, blank=True)

    def __unicode__(self):
        return u"{0}-{1}".format(self.id, self.slug)

    def get_absolute_url(self):
        if self.date_available <= timezone.now() and self.published:
            return self.image.url
        return u""<commit_msg>Create TaggedImage, unique marker for image<commit_after># -*- coding: utf-8 -*-
import uuid
import os
from datetime import datetime

from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone

from taggit.models import TaggedItemBase
from taggit.managers import TaggableManager

from opps.core.models import Publishable


def get_file_path(instance, filename):
    ext = filename.split('.')[-1]
    filename = "{0}-{1}.{2}".format(uuid.uuid4(), instance.slug, ext)
    d = datetime.now()
    folder = "images/{0}".format(d.strftime("%Y/%m/%d/"))
    return os.path.join(folder, filename)


class TaggedImage(TaggedItemBase):
    """Tag for images """
    content_object = models.ForeignKey('images.Image')
    pass


class Image(Publishable):

    title = models.CharField(_(u"Title"), max_length=140, db_index=True)
    slug = models.SlugField(_(u"Slug"), max_length=150, blank=True,
                            db_index=True)
    image = models.ImageField(upload_to=get_file_path)
    description = models.TextField(_(u"Description"), null=True, blank=True)
    tags = TaggableManager(blank=True, through=TaggedImage)

    source = models.ForeignKey('sources.Source', null=True, blank=True)

    def __unicode__(self):
        return u"{0}-{1}".format(self.id, self.slug)

    def get_absolute_url(self):
        if self.date_available <= timezone.now() and self.published:
            return self.image.url
        return u""
{'fraction_non_alphanumeric': 0.133381660021747, 'fraction_numerical': 0.010873504893077202, 'mean_word_length': 3.7586206896551726, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1267017', 'n_tokens_mistral': 886, 'n_tokens_neox': 870, 'n_words': 191}