2023-03-10 12:50:14 +00:00
import os , sys
from utils . inspector import generate_hashes_gradebook , generate_duplicate_hashes_gradebook
def main ( ) :
2023-03-16 20:40:20 +00:00
gradebook_dir_name = ' ' . join ( sys . argv [ 1 : ] ) if len ( sys . argv ) > 1 else exit ( f ' \n No gradebook directory name given. Provide the name as an argument. \n \n Usage: python { sys . argv [ 0 ] } [gradebook dir name] \n Example: python { sys . argv [ 0 ] } AssignmentX \n ' )
2023-03-10 12:50:14 +00:00
gradebook_dir_path = os . path . join ( ' BB_gradebooks ' , gradebook_dir_name )
2023-03-16 20:40:20 +00:00
if not os . path . exists ( gradebook_dir_path ) :
exit ( ' [Info] Gradebook directory does not exist - nothing to inspect ' )
if not os . listdir ( gradebook_dir_path ) : # if no files in gradebook dir
exit ( f ' [Info] No files found in this gradebook - nothing to inspect ' )
2023-03-10 12:50:14 +00:00
# generate CSV file with hashes for all files in gradebook & return path to CSV file for finding duplicate hashes
hashes_csv_file_path = generate_hashes_gradebook ( gradebook_dir_path )
# generate CSV file with files having duplicate hashes
generate_duplicate_hashes_gradebook ( hashes_csv_file_path )
if __name__ == ' __main__ ' :
main ( )