Skip to content

Commit 103c33b

Browse files
committed
Resolve issues on Windows by escaping path separators first
1 parent a0f966e commit 103c33b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nbgrader/coursedir.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,13 @@ def find_notebooks(
438438
for key, value in kwargs.items()
439439
}
440440

441-
# Convert to a Path and back to a string to remove any instances of `/.`
442-
pattern = str(Path(pattern.replace(".", r"\.").format(**pattern_args)))
443-
441+
# Escape backslashes on Windows before doing any other escaping
444442
if sys.platform == 'win32':
445-
# Escape backslashes on Windows
446443
pattern = pattern.replace('\\', r'\\')
447444

445+
# Convert to a Path and back to a string to remove any instances of `/.`
446+
pattern = str(Path(pattern.replace(".", r"\.").format(**pattern_args)))
447+
448448
for file in files:
449449
match = re.match(pattern, str(file.relative_to(self.root)))
450450
if match:

0 commit comments

Comments
 (0)