Last active
March 15, 2024 07:10
-
-
Save bfritscher/b039cc4d1e33efc884a37fb7ddda923f to your computer and use it in GitHub Desktop.
Revisions
-
bfritscher revised this gist
Mar 15, 2024 . 1 changed file with 12 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,11 @@ import csv from collections import defaultdict # Usage on windows # gh classroom clone student-repos # add classroom_roster.csv # rename root folder and match prefix assignment_prefix = 'vuejs-evaluation-ne-' index = {} folders = defaultdict(lambda: 'other') @@ -13,14 +17,15 @@ with open('classroom_roster.csv') as csvfile: spamreader = csv.DictReader(csvfile) for row in spamreader: index[f"{assignment_prefix}{row['github_username']}"] = row from pathlib import Path for fd in ['ne', 'ge', 'vs', 'other']: Path(f"./sorted_{assignment_prefix}/{fd}").mkdir(parents=True, exist_ok=True) # for folder move it to the right folder and rename it assignments = list([fd for fd in glob.glob('*', root_dir=assignment_prefix)]) print(f"found assignments {len(assignments)}") for fd in assignments: dest_dir = 'other' ident = fd @@ -30,8 +35,9 @@ dest_dir = folders[row['identifier'].split('@')[1]] ident = f"{row['identifier'].split('@')[0]}_{fd}" print(dest_dir, fd, row['identifier']) src = os.path.join(assignment_prefix, fd) dest = os.path.join(f"sorted_{assignment_prefix}", dest_dir, ident) cmd = f"xcopy {src} {dest} /E/H/C/I" print(cmd) os.system(cmd)
-
bfritscher created this gist
Mar 24, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ import glob import os import csv from collections import defaultdict assignment = 'vuejs-evaluation-03-24-2023-11-56-56' index = {} folders = defaultdict(lambda: 'other') folders['he-arc.ch'] = 'ne' folders['etu.hesge.ch'] = 'ge' folders['students.hevs.ch'] = 'vs' with open('classroom_roster.csv') as csvfile: spamreader = csv.DictReader(csvfile) for row in spamreader: index[row['github_username']] = row from pathlib import Path for fd in ['ne', 'ge', 'vs', 'other']: Path(f"./sorted_{assignment}/{fd}").mkdir(parents=True, exist_ok=True) # for folder move it to the right folder and rename it assignments = list([fd for fd in glob.glob('*', root_dir=assignment)]) for fd in assignments: dest_dir = 'other' ident = fd if fd in index: row = index[fd] if '@' in row['identifier']: dest_dir = folders[row['identifier'].split('@')[1]] ident = f"{row['identifier'].split('@')[0]}_{fd}" print(dest_dir, fd, row['identifier']) src = os.path.join(assignment, fd) dest = os.path.join(f"sorted_{assignment}", dest_dir, ident) cmd = f"xcopy {src} {dest} /E/H/C/I" print(cmd) os.system(cmd)