Skip to content

Commit 1f1927b

Browse files
[Feature:Plagiarism] Subtractive regex for student files (#56)
* Add ability to exclude files by putting an "!" before regex * "!" character removes files from the selection instead of adding everything except files
1 parent 9cbffa4 commit 1f1927b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

bin/concatenate_all.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,18 @@ def getConcatFilesInDir(input_dir, regex_patterns):
2929
files = sorted(my_files)
3030
if regex_patterns[0] != "":
3131
files_filtered = []
32+
# resolve all of the additions
3233
for e in regex_patterns:
33-
files_filtered.extend(fnmatch.filter(files, e.strip()))
34+
# Regex patterns starting with a ! indicate that files should be excluded
35+
if not e.strip().startswith("!"):
36+
files_filtered.extend(fnmatch.filter(files, e.strip()))
37+
38+
# resolve the subtractions
39+
for e in regex_patterns:
40+
if e.strip().startswith("!"):
41+
files_filtered = [file for file in files_filtered if file not in
42+
fnmatch.filter(files_filtered, e.strip().replace("!", ""))]
43+
3444
files = files_filtered
3545

3646
for my_file in files:

0 commit comments

Comments
 (0)