Skip to content

Commit

Permalink
Merge pull request #1341 from lzach/format_path_fix
Browse files Browse the repository at this point in the history
Make format_path behave the same for absolute paths
  • Loading branch information
BertR authored Jun 26, 2020
2 parents 5a81fd5 + d31cbb7 commit b5ae9f8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nbgrader/coursedir.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,12 @@ def format_path(self, nbgrader_step: str, student_id: str, assignment_id: str, e
)

if escape:
base = re.escape(self.root)
structure = [x.format(**kwargs) for x in full_split(self.directory_structure)]
path = re.escape(os.path.sep).join([base] + structure)
if len(structure) == 0 or not structure[0].startswith(os.sep):
base = [re.escape(self.root)]
else:
base = []
path = re.escape(os.path.sep).join(base + structure)
else:
path = os.path.join(self.root, self.directory_structure.format(**kwargs))

Expand Down

0 comments on commit b5ae9f8

Please sign in to comment.