@@ -97,11 +97,32 @@ def main():
9797 # Remove concat file if there no content...
9898 if total_concat == 0 :
9999 os .remove (my_concatenated_file )
100+ # FIXME: is this the correct path?
100101 p2 = os .path .join (course_dir , "lichen" , "tokenized" , gradeable , user , version )
101102 if os .path .isdir (p2 ):
102103 shutil .rmtree (p2 )
103104 os .rmdir (my_concatenated_dir )
104105
106+ # =========================================================================
107+ # concatenate any files in the provided_code directory
108+ provided_code_path = os .path .join (course_dir , "lichen" , "provided_code" , gradeable )
109+ output_dir = os .path .join (course_dir , "lichen" , "concatenated" ,
110+ gradeable , "provided_code" , "provided_code" )
111+ output_file = os .path .join (output_dir , "submission.concatenated" )
112+
113+ if os .path .isdir (provided_code_path ) and len (os .listdir (provided_code_path )) != 0 :
114+ # If the directory already exists, delete it and make a new one
115+ if os .path .isdir (output_dir ):
116+ shutil .rmtree (output_dir )
117+ os .makedirs (output_dir )
118+
119+ with open (output_file , 'w' ) as of :
120+ # Loop over all of the provided files and concatenate them
121+ for file in sorted (os .listdir (provided_code_path )):
122+ with open (os .path .join (provided_code_path , file ), encoding = 'ISO-8859-1' ) as tmp :
123+ # append the contents of the file
124+ of .write (tmp .read ())
125+
105126 print ("done" )
106127
107128
0 commit comments