Skip to content

Commit b5ae9f8

Browse files
authored
Merge pull request #1341 from lzach/format_path_fix
Make format_path behave the same for absolute paths
2 parents 5a81fd5 + d31cbb7 commit b5ae9f8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

nbgrader/coursedir.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,12 @@ def format_path(self, nbgrader_step: str, student_id: str, assignment_id: str, e
276276
)
277277

278278
if escape:
279-
base = re.escape(self.root)
280279
structure = [x.format(**kwargs) for x in full_split(self.directory_structure)]
281-
path = re.escape(os.path.sep).join([base] + structure)
280+
if len(structure) == 0 or not structure[0].startswith(os.sep):
281+
base = [re.escape(self.root)]
282+
else:
283+
base = []
284+
path = re.escape(os.path.sep).join(base + structure)
282285
else:
283286
path = os.path.join(self.root, self.directory_structure.format(**kwargs))
284287

0 commit comments

Comments
 (0)