# ----------------------------------------------------------------
# This module defines metadata to be used by the batchSVN.py script.
#
# Copy this module as /class/csse/<courseName>/scripts/batchSVNData.py and 
# edit it to define the course metadata for <courseName>.  The sample data
# in the original file can be used by invoking the batchSVN.py script using
# "testing" as the course name argument, e.g.: ./batchSVN.py testing
# ----------------------------------------------------------------

import os
import sys

# ----------------------------------------------------------------
# Hacks the system path so the import of batchSVNTypes works for testing 
# individual course meta-data on the the server.
serverPathToBatchSVN = "/class/csse/resources/Grading"
# Change the following line to point to your local checkout of the CSSE
# resources trunk if you want to test this file on your local machine:
localMachinePathToBatchSVN = "/Users/cclifton/Documents/Rose/Administrative/resources/Grading"
sys.path.append(serverPathToBatchSVN)
sys.path.append(localMachinePathToBatchSVN)
from batchSVNTypes import *
# ----------------------------------------------------------------

# ----------------------------------------------------------------
# Local variables
# ----------------------------------------------------------------

repoNamePrefix = 'csse120-201410-'

# replace the following with a description of the course, like 'CSSE 120'
courseDescription = 'CSSE 120'
print(courseDescription)
num_sections = 4    #201410
term = '201410'

students_by_section = {}
all_students = []
repoSets = []
for sec in range(1, num_sections + 1):
    sectionFile = open('/class/csse/csse120/scripts/csse120-' + term + '-' + str(sec) +\
                     '-users.txt', 'r')
    students_by_section[sec] = list()
    for line in sectionFile:
        students_by_section[sec].append(line.strip())
    sectionFile.close()
    all_students += students_by_section[sec]
# ----------------------------------------------------------------
# Defines repositories sets for this course.  Used by main script.
# ----------------------------------------------------------------
reposSets = []
reposSets.append(RepositorySet("All Students", repoNamePrefix, all_students))
reposSets.append(RepositorySet("Mutchler Students", repoNamePrefix, 
                 students_by_section[1] + students_by_section[2]))
reposSets.append(RepositorySet("Anderson Students", repoNamePrefix,  
                 students_by_section[3] + students_by_section[4]))

for sec in range(1, num_sections + 1):
    reposSets.append(RepositorySet("Section " + str(sec), repoNamePrefix, students_by_section[sec]))

repoSets.append(RepositorySet("projectCWA", repoNamePrefix, [
    "team31-blanknc-hansonac-wrightjt",
    "team32-blomejd-loganga-szatkosa",
    "team33-coleam-schulta1-smithij",
    "team34-doolansr-maas-zhenga",
    "team35-gateslm-horstmpr-trottasn",
    "team36-guytd-howtc-morganml",
    "team37-knispeja-larsonp-solyss",
    "team38-mot-tandoni-zhangc",
    "team41-abreum-havensid-koontzaj",
    "team42-bellisjr-burchtm-reevesaj",
    "team43-chenp1-tongy-xiaox",
    "team44-erexsolr-mcphersm-peruman",
    "team45-harrislb-prestojn-richarel",
    "team46-jiangx1-lewd-lubarsva-zhengj",
    "team47-miskowbs-pengb-shellajt",
    ]))

""" Example:
reposSets.append(RepositorySet("pascal", repoNamePrefix, [
    "pascal10",
    "pascal11",
    "pascal12",
    "pascal13",
    "pascal14",
    "pascal15",
    "pascal16",
    "pascal17",
    "pascal18",
    "pascal19",
    "pascal20",
    "pascal21",
    "pascal22",
    "pascal23",
    "pascal24",
    "pascal25",
]))
"""  # end the long quote


reposSets.append(RepositorySet("SmallSetforTesting", repoNamePrefix, [
    "anderson", "mutchler"
]))

# ----------------------------------------------------------------
# Defines project names and unit tests for this course. 
# Used by main script.
# ----------------------------------------------------------------
projects = []
#projects.append(Project("WarmUpAndStretchingWithUnitTests", "anagram.AnagramTests", "list.SortedListTests.java",
#                        "priorityQueue.PQTests.java", "hardysTaxi.HardyTests.java"))
projects.append(Project("BOGUS_ZERO_SO_REST_OF_NUMBERS_COME_OUT_RIGHT"))
projects.append(Project("Session01_IntroductionToPython"))
projects.append(Project("Session02_InputComputeOutput"))
projects.append(Project("Session03_LoopsAndUsingObjects")) 
projects.append(Project("Session04_FunctionsAndAccumulators"))
projects.append(Project("Session05_RobotsConditionalsAndAccumulators"))
projects.append(Project("Session06_TheAccumulatorPattern"))
projects.append(Project("Session07_Test1Practice"))
projects.append(Project("Session08_WaitingUntilEventsAndRobots"))
projects.append(Project("Session09_Exam1_201410"))
projects.append(Project("Session10_Sequences"))
projects.append(Project("Session11_AccumulatingSequencesAndFancyIterating"))
projects.append(Project("Session12_RobotSongsAndSequences"))
projects.append(Project("Session13_ReferencesToObjects"))
projects.append(Project("Session14_Test2Practice"))
projects.append(Project("Session15_Strings"))
projects.append(Project("Session16_DefiningClasses_Part1"))
projects.append(Project("Session17_Test2_201410"))
projects.append(Project("Session18_DefiningClasses_Part2"))
projects.append(Project("Session19_DefiningClasses_Part1"))
projects.append(Project("Practice_Project_201410"))
projects.append(Project("ZProject_201410"))



# ----------------------------------------------------------------
# Defines any additional main menu commands for this course.
# Used by main script.
# ----------------------------------------------------------------
menuItems = []
# ----------------------------------------------------------------
# Sample code to add a zip command to the menu:
# def zipForDownload(data):
#     if os.access(data.activeProject.name,os.F_OK):
#         os.system('zip -r %s.zip %s' % (data.activeProject.name,
#                                         data.activeProject.name))
#         if not os.access(data.activeProject.name + '.zip',os.F_OK):
#             print '\a\n*** Unable to create zip file ***\n'
#     return False
# menuItems.append(MenuItem('Zip local project subdirectory for download',
#                           zipForDownload))
# ----------------------------------------------------------------

# ----------------------------------------------------------------
# A couple of extra menu items that are useful in a pinch, but aren't yet 
# sufficiently abstracted for general use.
# def copyInExtras(data):
#     forEachRepo("cp ${scriptDir}/*.java ${shortName}/src/btwp/", data)
#     return False
# menuItems.append(MenuItem('Copy in Exam2 test files',copyInExtras))
# 
# def runTestsExtraMem(data):
#     forEachRepo("cd ${shortName} && java -Xmx2000m -cp '${scriptDir}/junit-4.5.jar:bin' org.junit.runner.JUnitCore ${testClasses}", data)
#     return False
# menuItems.append(MenuItem('Run JUnit tests with extra memory',runTestsExtraMem))
# ----------------------------------------------------------------
   


# ----------------------------------------------------------------
# Some test code, executed if this file is imported directly into
# a python shell.  Shouldn't need to change this when specifying
# course-specific data above.
# ----------------------------------------------------------------
if __name__ == '__main__':
    # print "reposSets ==", reposSets
    for i in range(len(repoSets)):
        print "Repositories from reposSets[i]:\n"
        for r in reposSets[i].repos():
            print "   ", r, '\n'
    print "repository names: ", [r.name for r in reposSets], '\n'
    print
    print projects
    print "Test classes:"
    for p in projects:
        print "   %s: %s" % (p.name, p.testClasses)
    print "Additional Menu Items' Text:"
    for mi in menuItems:
        print "  ", mi.text