<commit_before># -*- coding: utf-8 -*-

from django.db import models
from django.utils.translation import ugettext_lazy as _
from Patcher.utils import file_cleanup
from django.db.models.signals import post_delete


class Soft(models.Model):
    name    = models.CharField(_("Name"),max_length=255,unique=True)
    slug    = models.SlugField(_("Slug"),max_length=32,unique=True)

    def __unicode__(self):
        return u"%s" % self.name

class Version(models.Model):
    BIT_CHOICE = (32,64)

    soft    = models.ForeignKey(Soft,null=False,blank=False)
    number  = models.IntegerField(_("Number"),help_text=_("Format is xxxxyyzz where xxxx is the Major version, yy the minor and zz the patch"))
    os      = models.CharField(_("os name"),max_length=128)
    bit     = models.IntegerField(_("Bit number"),choices=[(x,x) for x in BIT_CHOICE])


    def get_version(self):
        major = self.number / (100*100)
        minor = self.number / 100 - major*100
        patch = self.number - (minor + major*100)*100
        return (major, minor,patch)

    @staticmethod
    def version_to_number(major,minor,patch):
        return patch + (minor + (major *100))*100

    def __unicode__(self):
        (major,minor,patch) = self.get_version()
        return u"%s-%s-x%d.%d.%d.%d" % (self.soft.slug,self.os,self.bit,major,minor,patch)

class File(models.Model):
    def get_upload_dir(self,filename):
        (major,minor,patch) = self.version.get_version()
        return "%s/%d.%d.%d/%s-x%d/%s" % (self.version.soft.slug,major,minor,patch,self.version.os,self.version.bit,filename)

    version = models.ForeignKey(Version)
    file    = models.FileField(_("File"),upload_to=get_upload_dir)
    action  = models.IntegerField(_("Action"),choices=[(0,"unknow"),(1,"New"),(2,"Maj"),(3,"Deleted")],default=0)


    def __unicode__(self):
        return u"%s-%s" % (self.version,self.file)
post_delete.connect(file_cleanup, sender=File, dispatch_uid="File.file_cleanup")
<commit_msg>change function name<commit_after># -*- coding: utf-8 -*-

from django.db import models
from django.utils.translation import ugettext_lazy as _
from Patcher.utils import file_cleanup
from django.db.models.signals import post_delete


class Soft(models.Model):
    name    = models.CharField(_("Name"),max_length=255,unique=True)
    slug    = models.SlugField(_("Slug"),max_length=32,unique=True)

    def __unicode__(self):
        return u"%s" % self.name

class Version(models.Model):
    BIT_CHOICE = (32,64)

    soft    = models.ForeignKey(Soft,null=False,blank=False)
    number  = models.IntegerField(_("Number"),help_text=_("Format is xxxxyyzz where xxxx is the Major version, yy the minor and zz the patch"))
    os      = models.CharField(_("os name"),max_length=128)
    bit     = models.IntegerField(_("Bit number"),choices=[(x,x) for x in BIT_CHOICE])


    def get_version(self):
        major = self.number / (100*100)
        minor = self.number / 100 - major*100
        patch = self.number - (minor + major*100)*100
        return (major, minor,patch)

    @staticmethod
    def version_to_number(major,minor,patch):
        return patch + (minor + (major *100))*100

    def __unicode__(self):
        (major,minor,patch) = self.get_version()
        return u"%s-%s-x%d.%d.%d.%d" % (self.soft.slug,self.os,self.bit,major,minor,patch)

class File(models.Model):
    def get_upload_filename(self,filename):
        (major,minor,patch) = self.version.get_version()
        return "%s/%d.%d.%d/%s-x%d/%s" % (self.version.soft.slug,major,minor,patch,self.version.os,self.version.bit,filename)

    version = models.ForeignKey(Version)
    file    = models.FileField(_("File"),upload_to=get_upload_filename)
    action  = models.IntegerField(_("Action"),choices=[(0,"unknow"),(1,"New"),(2,"Maj"),(3,"Deleted")],default=0)


    def __unicode__(self):
        return u"%s-%s" % (self.version,self.file)
post_delete.connect(file_cleanup, sender=File, dispatch_uid="File.file_cleanup")

{'fraction_non_alphanumeric': 0.15589640432486798, 'fraction_numerical': 0.02112144832788534, 'mean_word_length': 3.929368029739777, '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': '6767803', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1324, 'n_words': 238}