<commit_before>from django.db import models


# I don't remember where I was going with the ProjectManager class...
# 
# class ProjectManager(models.Manager):
#     '''
#     '''
#     def create_project(self, path):
#         project = self.create(root=path)

#         # <this is where we would populate the db>

#         return project

# Create your models here.
class Project(models.Model):
    root = models.CharField(max_length=2048, unique=True)
#    objects = ProjectManager()

    def __unicode__(self):
        return self.root

class Collection(models.Model):
    '''
    A collection of keywords (eg: a resource file or library)
    '''
    project = models.ForeignKey(Project, null=True)
    path = models.CharField(max_length=2048, null=True)
    name = models.CharField(max_length=256)
    collection_type = models.CharField(max_length=8, 
                                       choices=(
                                           ("library", "Library"), 
                                           ("resource", "Resource file"),
                                           ("suite", "Test suite"),
                                       ),
    )
    version = models.CharField(max_length=12, blank=True)
    scope = models.CharField(max_length=6, 
                             choices=(("global", "Global"),
                                      ("suite", "Test suite"),
                                      ("test", "Test case")),
                             default="global")
    namedargs = models.CharField(blank=True, max_length=2048)
    doc_format = models.CharField(max_length=10, 
                                  choices=(("HTML", "HTML"),
                                           ("TEXT", "Plain text"),
                                           ("ROBOT", "Robot"),
                                           ("reST", "reStructured Text")),
                                  default="ROBOT")
    doc = models.TextField(blank=True)

    def __unicode__(self):
        if self.path is None:
            return unicode(self.name)
        else:
            return unicode(self.path)

class Testcase(models.Model):
    collection = models.ForeignKey(Collection)
    name = models.CharField(max_length=256) # what is the actual robot limit?
    doc = models.TextField("Documentation", blank=True)<commit_msg>added keywords method to Collection model<commit_after>from django.db import models


# The more I think about it, the more useless this class becomes.
# Does this app really need to track projects?
class Project(models.Model):
    root = models.CharField(max_length=2048, unique=True, null=False)

    def __unicode__(self):
        return self.root

class Collection(models.Model):
    '''
    A collection of keywords (eg: a resource file or library)
    '''

    path = models.CharField(max_length=2048, null=False, unique=True)
    name = models.CharField(max_length=256)
    collection_type = models.CharField(max_length=8, 
                                       choices=(
                                           ("library", "Library"), 
                                           ("resource", "Resource file"),
                                           ("suite", "Test suite"),
                                       ),
    )
    doc = models.TextField(blank=True)
    doc_format = models.CharField(max_length=10, 
                                  choices=(("HTML", "HTML"),
                                           ("TEXT", "Plain text"),
                                           ("ROBOT", "Robot"),
                                           ("reST", "reStructured Text")),
                                  default="ROBOT")

    # these three only apply to libraries, not resource files
    # or test suites. Should I use a separate model for libraries,
    # resource files and so on? I guess this is good enough for now.
    version = models.CharField(max_length=12, blank=True)
    scope = models.CharField(max_length=6, 
                             choices=(("global", "Global"),
                                      ("suite", "Test suite"),
                                      ("test", "Test case"),
                                      ("", "none")),
                             default="global")
    namedargs = models.CharField(blank=True, max_length=2048)

    def keywords(self):
        return Keyword.objects.filter(collection=self)

    def __unicode__(self):
        if self.path is None:
            return unicode(self.name)
        else:
            return unicode(self.path)

class Testcase(models.Model):
    collection = models.ForeignKey(Collection)
    name = models.CharField(max_length=256) # what is the actual robot limit?
    doc = models.TextField("Documentation", blank=True)
{'fraction_non_alphanumeric': 0.10572687224669604, 'fraction_numerical': 0.010069225928256766, 'mean_word_length': 1.5689655172413792, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 38, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3167702', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1127, 'n_words': 299}