summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Turner <9087854+AA-Turner@users.noreply.github.com>2023-04-28 09:55:14 +0100
committerGitHub <noreply@github.com>2023-04-28 09:55:14 +0100
commitce606d82cd03c9ed28b26aac918f060382122779 (patch)
tree52549f5ad6393e9045656a353190090184d960ea
parent262e1d9857f28c4a97f1325a43c7fd981a13900c (diff)
downloadsphinx-git-ce606d82cd03c9ed28b26aac918f060382122779.tar.gz
Removed deprecated ``sphinx.util.get_matching_files()`` function (#11373)
-rw-r--r--CHANGES1
-rw-r--r--sphinx/util/__init__.py40
2 files changed, 2 insertions, 39 deletions
diff --git a/CHANGES b/CHANGES
index ed9ac8ddc..836527529 100644
--- a/CHANGES
+++ b/CHANGES
@@ -20,6 +20,7 @@ Incompatible changes
* #11370: Remove deprecated ``sphinx.util.stemmer`` module.
* #11371: Remove deprecated ``sphinx.pycode.ast.parse()`` function.
* #11372: Remove deprecated ``sphinx.io.read_doc()`` function.
+* #11373: Removed deprecated ``sphinx.util.get_matching_files()`` function.
Deprecated
----------
diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py
index 65eaea8a9..2f166852c 100644
--- a/sphinx/util/__init__.py
+++ b/sphinx/util/__init__.py
@@ -7,13 +7,11 @@ import os
import posixpath
import re
import sys
-import warnings
from importlib import import_module
from os import path
-from typing import IO, Any, Iterable
+from typing import IO, Any
from urllib.parse import parse_qsl, quote_plus, urlencode, urlsplit, urlunsplit
-from sphinx.deprecation import RemovedInSphinx70Warning
from sphinx.errors import ExtensionError, FiletypeNotFoundError
from sphinx.locale import __
from sphinx.util import display as _display
@@ -42,7 +40,6 @@ from sphinx.util.osutil import ( # noqa: F401
os_path,
relative_uri,
)
-from sphinx.util.typing import PathMatcher
logger = logging.getLogger(__name__)
@@ -58,41 +55,6 @@ def docname_join(basedocname: str, docname: str) -> str:
posixpath.join('/' + basedocname, '..', docname))[1:]
-def get_matching_files(dirname: str,
- exclude_matchers: tuple[PathMatcher, ...] = (),
- include_matchers: tuple[PathMatcher, ...] = ()) -> Iterable[str]:
- """Get all file names in a directory, recursively.
-
- Exclude files and dirs matching some matcher in *exclude_matchers*.
- """
- path_stabilize = _osutil.path_stabilize # avoid warning
-
- warnings.warn("'sphinx.util.get_matching_files' is deprecated, use "
- "'sphinx.util.matching.get_matching_files' instead. Note that"
- "the types of the arguments have changed from callables to "
- "plain string glob patterns.", RemovedInSphinx70Warning, stacklevel=2)
- # dirname is a normalized absolute path.
- dirname = path.normpath(path.abspath(dirname))
-
- for root, dirs, files in os.walk(dirname, followlinks=True):
- relativeroot = path.relpath(root, dirname)
- if relativeroot == ".":
- relativeroot = "" # suppress dirname for files on the target dir
-
- qdirs = enumerate(path_stabilize(path.join(relativeroot, dn))
- for dn in dirs) # type: Iterable[tuple[int, str]]
- qfiles = enumerate(path_stabilize(path.join(relativeroot, fn))
- for fn in files) # type: Iterable[tuple[int, str]]
- for matcher in exclude_matchers:
- qdirs = [entry for entry in qdirs if not matcher(entry[1])]
- qfiles = [entry for entry in qfiles if not matcher(entry[1])]
-
- dirs[:] = sorted(dirs[i] for (i, _) in qdirs)
-
- for _i, filename in sorted(qfiles):
- yield filename
-
-
def get_filetype(source_suffix: dict[str, str], filename: str) -> str:
for suffix, filetype in source_suffix.items():
if filename.endswith(suffix):