Skip to content

Commit 872894f

Browse files
committed
Add logging to figure out these Windows failures
1 parent 103c33b commit 872894f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

nbgrader/coursedir.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import typing
66
from pathlib import Path
77
from textwrap import dedent
8+
import logging
89

910
from traitlets.config import LoggingConfigurable
1011
from traitlets import Integer, Bool, Unicode, List, default, validate, TraitError
@@ -379,12 +380,14 @@ def find_assignments(self,
379380
}
380381

381382
# Convert to a Path and back to a string to remove any instances of `/.`
382-
pattern = str(Path(self.directory_structure.format(**pattern_args)))
383+
pattern = str(self.directory_structure)
383384

385+
# Escape backslashes on Windows before doing any other escaping
384386
if sys.platform == 'win32':
385-
# Escape backslashes on Windows
386387
pattern = pattern.replace('\\', r'\\')
387388

389+
pattern = str(Path(self.directory_structure.format(**pattern_args)))
390+
388391
for dir in dirs:
389392
match = re.match(pattern, str(dir.relative_to(self.root)))
390393
if match:
@@ -438,14 +441,21 @@ def find_notebooks(
438441
for key, value in kwargs.items()
439442
}
440443

444+
logging.error("unescaped pattern: %s", pattern)
445+
441446
# Escape backslashes on Windows before doing any other escaping
442447
if sys.platform == 'win32':
443448
pattern = pattern.replace('\\', r'\\')
444449

450+
logging.error("winescaped pattern: %s", pattern)
451+
445452
# Convert to a Path and back to a string to remove any instances of `/.`
446453
pattern = str(Path(pattern.replace(".", r"\.").format(**pattern_args)))
447454

455+
logging.error("final pattern: %s", pattern)
456+
448457
for file in files:
458+
loggging.error("file: %s", file.relative_to(self.root))
449459
match = re.match(pattern, str(file.relative_to(self.root)))
450460
if match:
451461
results.append({ **kwargs, **match.groupdict(), "path": file })

0 commit comments

Comments
 (0)