'''TODO: Cat command docs
'''
import logging
import os

from grader.models import Grader
from grader.utils.config import require_grader_config

logger = logging.getLogger(__name__)

help = "Print an assignment's grade output to STDOUT"


def setup_parser(parser):
    parser.add_argument('--submission_id', type=str,
                        help='ID of specific submission to cat.')
    parser.add_argument('assignment',
                        help='Name of the assignment.')
    parser.add_argument('student_id',
                        help='ID of the student.')
    parser.set_defaults(run=run)


def timestamp(path):
    return os.stat(path).st_mtime


def last_graded(submission):
    latest_result = max(submission.results_files, key=timestamp)
    return os.stat(latest_result).st_mtime


@require_grader_config
def run(args):
    g = Grader(args.path)
    a = g.get_assignment(args.assignment)

    try:
        submissions = a.submissions_by_user[args.student_id]
    except KeyError:
        logger.error("Cannot find student %s", args.student_id)
        return

    latest_submission = max(submissions, key=last_graded)
    latest_result = max(latest_submission.results_files, key=timestamp)
    logger.debug("Catting %s", latest_result)
    with open(latest_result) as f:
        print(f.read())

@@ -602,174 +602,63 @@
 def 
-timestamp(path):%0A    return os.stat(path).st_mtime%0A%0A%0Adef last_graded(submission):%0A    latest_result = max(submission.results_files, key=timestamp)%0A    return os.stat(
+last_graded(submission):%0A    return os.stat(submission.
 late
@@ -1019,80 +1019,8 @@
 ed)%0A
-    latest_result = max(latest_submission.results_files, key=timestamp)%0A
     
@@ -1046,16 +1046,34 @@
 ng %25s%22, 
+latest_submission.
 latest_r
@@ -1096,24 +1096,42 @@
 open(latest_
+submission.latest_
 result) as f

Use latest_results in "cat" command