Skip to content

Commit ea2c002

Browse files
committed
Update is_ignored to use fnmatch instead of glob
1 parent 7c87b46 commit ea2c002

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

nbgrader/utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,14 @@ def self_owned(path):
272272
return get_osusername() == find_owner(os.path.abspath(path))
273273

274274

275-
def is_ignored(filename: str, ignore_globs: List[str] = None) -> bool:
275+
def is_ignored(filename: str, ignore_globs: List[str]) -> bool:
276276
"""Determines whether a filename should be ignored, based on whether it
277277
matches any file glob in the given list. Note that this only matches on the
278278
base filename itself, not the full path."""
279-
if ignore_globs is None:
280-
return False
281-
dirname = os.path.dirname(filename)
279+
280+
basename = os.path.basename(filename)
282281
for expr in ignore_globs:
283-
globs = glob.glob(os.path.join(dirname, expr))
284-
if filename in globs:
282+
if fnmatch.fnmatch(basename, expr):
285283
return True
286284
return False
287285

0 commit comments

Comments
 (0)