From ebf9fc45224fe558cbeac3a61256ef7910c37543 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 30 Jan 2024 19:20:13 +0000 Subject: [PATCH] Fix path issues on Windows --- sphinx_autobuild/ignore.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sphinx_autobuild/ignore.py b/sphinx_autobuild/ignore.py index 7c65939..cbc0e31 100644 --- a/sphinx_autobuild/ignore.py +++ b/sphinx_autobuild/ignore.py @@ -4,18 +4,17 @@ import re -def get_ignore(regular, regex_based): +def get_ignore(regular_patterns, regex_based): """Prepare the function that determines whether a path should be ignored.""" - regular_patterns = regular - regex_based_patterns = [re.compile(r) for r in regex_based] + regex_based_patterns = list(map(re.compile, regex_based)) def ignore(path): """Determine if path should be ignored.""" # Any regular pattern matches. for pattern in regular_patterns: - if fnmatch.fnmatch(path, pattern): + if path.startswith((pattern + os.sep, pattern + '/')): return True - if path.startswith(pattern + os.sep): + if fnmatch.fnmatch(path, pattern): return True # Any regular expression matches.