Skip to content

Commit 2fd6ca5

Browse files
andrewaikens87bmcutler
authored andcommitted
Allow regex for files in configuration (#15)
* regex for files * remove comment * regrex -> regex
1 parent 86f40c8 commit 2fd6ca5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

bin/concatenate_all.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import os
99
import json
1010
import sys
11+
import fnmatch
1112

1213
CONFIG_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', 'config')
1314
with open(os.path.join(CONFIG_PATH, 'submitty.json')) as open_file:
@@ -33,6 +34,10 @@ def main():
3334
semester = lichen_config_data["semester"]
3435
course = lichen_config_data["course"]
3536
gradeable = lichen_config_data["gradeable"]
37+
expressions = None
38+
if("regex" in lichen_config_data):
39+
#this assumes regex is seperated by a ','
40+
expressions = lichen_config_data["regex"].split(',')
3641

3742
# ===========================================================================
3843
# error checking
@@ -76,11 +81,17 @@ def main():
7681
# loop over all files in all subdirectories
7782
base_path = os.path.join(submission_dir,user,version)
7883
for my_dir,dirs,my_files in os.walk(base_path):
79-
for my_file in sorted(my_files):
84+
#Determine if regex should be used
85+
files = sorted(my_files)
86+
if(expressions != None):
87+
files_filtered = []
88+
for e in expressions:
89+
files_filtered.extend(fnmatch.filter(files, e.strip()))
90+
files = files_filtered
91+
for my_file in files:
8092
# skip the timestep
8193
if my_file == ".submit.timestamp":
8294
continue
83-
# TODO: skip files that should be ignored
8495
absolute_path=os.path.join(my_dir,my_file)
8596
relative_path=absolute_path[len(base_path):]
8697
# print a separator & filename

0 commit comments

Comments
 (0)