<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
barry.specs
===========
Classes for specifying assignments and submissions.

:copyright: (C) 2013, <NAME>
:license:   MIT/X11, see LICENSE for details
"""
from .utils import HasDirectory, run_command
import os

#: A completely fulfilled requirement.
COMPLETE = u'complete'

#: A partially fulfilled requirement.
PARTIAL = u'partial'

#: A completely missed requirement.
INCOMPLETE = u'incomplete'

#: An extra requirement completed.
EXTRA = u'extra'

#: An extra requirement skipped.
SKIPPED = u'skipped'

#: Something went wrong grading.
PROBLEM = u'problem'


class Submission(HasDirectory):
    """
    This represents a student submission for the assignment.

    :param assignment: The assignment used to grade this submission.
    :param name: The name of the student who submitted this assignment.
    :param directory: The directory the assignment is located in.
    """
    def __init__(self, assignment, name, directory):
        self.assignment = assignment
        self.name = name
        self.directory = directory

    def run_command(self, *command, **options):
        """
        Run a command in the submission directory, and return the
        corresponding Popen object.
        """
        options.setdefault("directory", self.directory)

        env = dict(RESOURCES=self.assignment.directory)
        if 'env' in options:
            env.update(options.get('env'))
        options['env'] = env

        return run_command(*command, **options)


class Assignment(HasDirectory):
    """
    This represents an assignment Barry will grade.

    :param directory: The path to a directory containing the assignment
                      resources.
    """
    #: The assignment's title.
    title = None

    #: The class to instantiate for submissions.
    #: This should probably be a subclass of `Submission`.
    submission_class = Submission

    def __init__(self, directory):
        self.directory = directory

    def run_command(self, *command, **options):
        """
        Run a command in the resource directory, and return the corresponding
        Popen object.
        """
        options.setdefault("directory", self.directory)

        env = dict(RESOURCES=self.directory)
        if 'env' in options:<commit_msg>Assignment and Submission always use absolute paths now<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
barry.specs
===========
Classes for specifying assignments and submissions.

:copyright: (C) 2013, <NAME>
:license:   MIT/X11, see LICENSE for details
"""
from .utils import HasDirectory, run_command
import os

#: A completely fulfilled requirement.
COMPLETE = u'complete'

#: A partially fulfilled requirement.
PARTIAL = u'partial'

#: A completely missed requirement.
INCOMPLETE = u'incomplete'

#: An extra requirement completed.
EXTRA = u'extra'

#: An extra requirement skipped.
SKIPPED = u'skipped'

#: Something went wrong grading.
PROBLEM = u'problem'


class Submission(HasDirectory):
    """
    This represents a student submission for the assignment.

    :param assignment: The assignment used to grade this submission.
    :param name: The name of the student who submitted this assignment.
    :param directory: The directory the assignment is located in.
    """
    def __init__(self, assignment, name, directory):
        self.assignment = assignment
        self.name = name
        self.directory = os.path.abspath(directory)

    def run_command(self, *command, **options):
        """
        Run a command in the submission directory, and return the
        corresponding Popen object.
        """
        options.setdefault("directory", self.directory)

        env = dict(RESOURCES=self.assignment.directory)
        if 'env' in options:
            env.update(options.get('env'))
        options['env'] = env

        return run_command(*command, **options)


class Assignment(HasDirectory):
    """
    This represents an assignment Barry will grade.

    :param directory: The path to a directory containing the assignment
                      resources.
    """
    #: The assignment's title.
    title = None

    #: The class to instantiate for submissions.
    #: This should probably be a subclass of `Submission`.
    submission_class = Submission

    def __init__(self, directory):
        self.directory = os.path.abspath(directory)

    def run_command(self, *command, **options):
        """
        Run a command in the resource directory, and return the corresponding
        Popen object.
        """
        options.setdefault("directory", self.directory)

        env = dict(RESOURCES=self.directory)
        if 'env' in options:
{'fraction_non_alphanumeric': 0.09978768577494693, 'fraction_numerical': 0.0029723991507431, 'mean_word_length': 2.9721753794266443, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4066866', 'n_tokens_mistral': 1295, 'n_tokens_neox': 1207, 'n_words': 438}