Skip to content

Commit 6496865

Browse files
author
nathan sprague
committed
updates to allow nested data in the scaffolding folder
1 parent 8f0ea02 commit 6496865

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

jmu_gradescope_utils/build_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ def build_zip(autograder_folder, zip_location):
112112

113113
# Add scaffolding code
114114
scaffold_path = Path(autograder_folder) / 'scaffolding'
115-
for path in scaffold_path.glob('*'):
116-
logging.info(f"Adding {path.name} to zip file")
117-
zip_file.write(path, arcname=path.name)
115+
for path in scaffold_path.glob('**/*'):
116+
lname = str(path).split(str(scaffold_path) + os.sep)[1]
117+
logging.info(f"Adding {lname} to zip file")
118+
zip_file.write(path, arcname=lname)
118119

119120
# Add the files that just need to be added...
120121
for file_name in files_to_copy:

jmu_gradescope_utils/utils.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,20 @@ def full_submission_path(filename=None):
1919

2020
if filename is None:
2121
return SUBMISSION_BASE
22-
elif os.path.dirname(filename) == SUBMISSION_BASE:
22+
elif SUBMISSION_BASE in os.path.dirname(filename):
2323
return filename
24-
elif os.path.dirname(filename) == '':
25-
return os.path.join(SUBMISSION_BASE, filename)
2624
else:
27-
raise ValueError("bad submission file path: " + filename)
25+
return os.path.join(SUBMISSION_BASE, filename)
2826

2927

3028
def full_source_path(filename=None):
3129

3230
if filename is None:
3331
return SOURCE_BASE
34-
elif os.path.dirname(filename) == SOURCE_BASE:
32+
elif SOURCE_BASE in os.path.dirname(filename):
3533
return filename
36-
elif os.path.dirname(filename) == '':
37-
return os.path.join(SOURCE_BASE, filename)
3834
else:
39-
raise ValueError("bad source file path: " + filename)
35+
return os.path.join(SOURCE_BASE, filename)
4036

4137

4238
def count_regex_matches(regex, filename, strip_comments=True):

scripts/convert.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ def convert_autograder(folder, backup=True):
1818

1919
config_files = ['docstring.cfg', 'flake8.cfg', 'requirements.txt']
2020
for f in config_files:
21-
shutil.copy(path / 'autograder' / f, path /'configurations' /f)
21+
try:
22+
shutil.copy(path / 'autograder' / f, path /'configurations' /f)
23+
except FileNotFoundError:
24+
print(f'{f} not in original autograder.')
2225

2326
for item in (path / 'autograder').glob('*.py'):
2427
if item.name != 'run_tests.py': # no need for this

0 commit comments

Comments
 (0)