Skip to content

Commit 08ca336

Browse files
[Refactor:Plagiarism] Change no files found warning (#59)
* Print error message instead of putting message at top of files * Remove unused line * Change text to reflect that it is a warning, not an error
1 parent 2ca693b commit 08ca336

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

bin/concatenate_all.py

+7-11
Original file line numberDiff line numberDiff line change
@@ -236,20 +236,17 @@ def main():
236236

237237
# ==========================================================================
238238
# iterate over all of the created submissions, checking to see if they are empty
239-
# and adding a message to the top if so (to differentiate empty files from errors in the UI)
240-
241-
no_files_match_error = "ERROR! No files matched provided regex in selected directories"
239+
# and printing a message if so
242240

243241
for user in os.listdir(os.path.join(args.basepath, "users")):
244242
user_path = os.path.join(args.basepath, "users", user)
245243
for version in os.listdir(user_path):
246244
version_path = os.path.join(user_path, version)
247245
my_concatenated_file = os.path.join(version_path, "submission.concatenated")
248-
with open(my_concatenated_file, "r+") as my_cf:
246+
with open(my_concatenated_file, "r") as my_cf:
249247
if my_cf.read() == "":
250-
my_cf.write(no_files_match_error)
251-
total_concat += sys.getsizeof(no_files_match_error)
252-
checkTotalSize(total_concat)
248+
print("Warning: No files matched provided regex in selected directories "
249+
f"for user {user} version {version}")
253250

254251
# do the same for the other gradeables
255252
for other_gradeable in prior_term_gradeables:
@@ -261,11 +258,10 @@ def main():
261258
for other_version in os.listdir(other_user_path):
262259
other_version_path = os.path.join(other_user_path, other_version)
263260
my_concatenated_file = os.path.join(other_version_path, "submission.concatenated")
264-
with open(my_concatenated_file, "r+") as my_cf:
261+
with open(my_concatenated_file, "r") as my_cf:
265262
if my_cf.read() == "":
266-
my_cf.write(no_files_match_error)
267-
total_concat += sys.getsizeof(no_files_match_error)
268-
checkTotalSize(total_concat)
263+
print("Warning: No files matched provided regex in selected directories "
264+
f"for user {other_user} version {other_version}")
269265

270266
# ==========================================================================
271267
# concatenate provided code

0 commit comments

Comments
 (0)