Skip to content

Commit

Permalink
Fix path filtering on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Sep 18, 2024
1 parent b134d97 commit 3fab261
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 8 additions & 5 deletions sphinx_autobuild/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ def main(argv=()):
)

watch_dirs = [src_dir] + args.additional_watched_dirs
ignore_dirs = args.ignore + [out_dir, args.warnings_file, args.doctree_dir]
ignore_handler = IgnoreFilter(
[Path(p).as_posix() for p in ignore_dirs if p],
args.re_ignore,
)
ignore_dirs = [
*args.ignore,
out_dir,
args.warnings_file,
args.doctree_dir,
]
ignore_dirs = list(filter(None, ignore_dirs))
ignore_handler = IgnoreFilter(ignore_dirs, args.re_ignore)
app = _create_app(watch_dirs, ignore_handler, builder, out_dir, url_host)

if not args.no_initial_build:
Expand Down
5 changes: 4 additions & 1 deletion sphinx_autobuild/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import fnmatch
import re
from pathlib import Path


class IgnoreFilter:
def __init__(self, regular, regex_based):
"""Prepare the function that determines whether a path should be ignored."""
self.regular_patterns = [*dict.fromkeys(regular)]
normalised_paths = [Path(p).resolve().as_posix() for p in regular]
self.regular_patterns = list(dict.fromkeys(normalised_paths))
self.regex_based_patterns = [*map(re.compile, dict.fromkeys(regex_based))]

def __repr__(self):
Expand All @@ -18,6 +20,7 @@ def __repr__(self):

def __call__(self, path):
"""Determine if 'path' should be ignored."""
path = Path(path).resolve().as_posix()
# Any regular pattern matches.
for pattern in self.regular_patterns:
# separators are normalised before creating the IgnoreFilter
Expand Down

0 comments on commit 3fab261

Please sign in to comment.