Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 66348a9

Browse filesBrowse files
committed
Rely on rglob support rather than os.walk.
In OSXInstalledFonts, the `fontext is None` path could never be taken, because `get_fontext_synonyms` never returns None.
1 parent 197bb59 commit 66348a9
Copy full SHA for 66348a9

File tree

Expand file treeCollapse file tree

6 files changed

+26
-36
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+26
-36
lines changed

‎doc/api/next_api_changes/2018-02-15-AL-deprecations.rst

Copy file name to clipboardExpand all lines: doc/api/next_api_changes/2018-02-15-AL-deprecations.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The following classes, methods, functions, and attributes are deprecated:
1313
- ``Annotation.arrow``,
1414
- ``cbook.GetRealpathAndStat``, ``cbook.Locked``,
1515
- ``cbook.is_numlike`` (use ``isinstance(..., numbers.Number)`` instead),
16-
``cbook.unicode_safe``
16+
``cbook.listFiles``, ``cbook.unicode_safe``
1717
- ``container.Container.set_remove_method``,
1818
- ``dates.DateFormatter.strftime_pre_1900``, ``dates.DateFormatter.strftime``,
1919
- ``font_manager.TempCache``,
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``font_manager.list_fonts`` now follows the platform's casefolding semantics
2+
````````````````````````````````````````````````````````````````````````````
3+
4+
i.e., it behaves case-insensitively on Windows only.

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -743,14 +743,11 @@ def _get_data_path_cached():
743743

744744

745745
def get_py2exe_datafiles():
746-
datapath = get_data_path()
747-
_, tail = os.path.split(datapath)
746+
data_path = Path(get_data_path())
748747
d = {}
749-
for root, _, files in os.walk(datapath):
750-
files = [os.path.join(root, filename) for filename in files]
751-
root = root.replace(tail, 'mpl-data')
752-
root = root[root.index('mpl-data'):]
753-
d[root] = files
748+
for path in filter(Path.is_file, data_path.glob("**/*")):
749+
(d.setdefault(str(path.parent.relative_to(data_path.parent)), [])
750+
.append(str(path)))
754751
return list(d.items())
755752

756753

‎lib/matplotlib/cbook/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook/__init__.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ def dedent(s):
676676
return result
677677

678678

679+
@deprecated("3.0")
679680
def listFiles(root, patterns='*', recurse=1, return_folders=0):
680681
"""
681682
Recursively list files

‎lib/matplotlib/font_manager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/font_manager.py
+12-18Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from functools import lru_cache
3636
import json
3737
import os
38+
from pathlib import Path
3839
import subprocess
3940
import sys
4041
from threading import Timer
@@ -150,12 +151,13 @@ def get_fontext_synonyms(fontext):
150151

151152
def list_fonts(directory, extensions):
152153
"""
153-
Return a list of all fonts matching any of the extensions,
154-
possibly upper-cased, found recursively under the directory.
154+
Return a list of all fonts matching any of the extensions, found
155+
recursively under the directory.
155156
"""
156-
pattern = ';'.join(['*.%s;*.%s' % (ext, ext.upper())
157-
for ext in extensions])
158-
return cbook.listFiles(directory, pattern)
157+
extensions = ["." + ext for ext in extensions]
158+
return [str(path)
159+
for path in filter(Path.is_file, Path(directory).glob("**/*.*"))
160+
if path.suffix in extensions]
159161

160162

161163
def win32FontDirectory():
@@ -231,21 +233,13 @@ def win32InstalledFonts(directory=None, fontext='ttf'):
231233

232234

233235
def OSXInstalledFonts(directories=None, fontext='ttf'):
234-
"""
235-
Get list of font files on OS X - ignores font suffix by default.
236-
"""
236+
"""Get list of font files on OS X."""
237237
if directories is None:
238238
directories = OSXFontDirectories
239-
240-
fontext = get_fontext_synonyms(fontext)
241-
242-
files = []
243-
for path in directories:
244-
if fontext is None:
245-
files.extend(cbook.listFiles(path, '*'))
246-
else:
247-
files.extend(list_fonts(path, fontext))
248-
return files
239+
return [path
240+
for directory in directories
241+
for ext in get_fontext_synonyms(fontext)
242+
for path in list_fonts(directory, ext)]
249243

250244

251245
@lru_cache()

‎tools/triage_tests.py

Copy file name to clipboardExpand all lines: tools/triage_tests.py
+4-10Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,10 @@ def find_failing_tests(result_images, source):
329329
Find all of the failing tests by looking for files with
330330
`-failed-diff` at the end of the basename.
331331
"""
332-
entries = []
333-
for root, dirs, files in os.walk(result_images):
334-
for fname in files:
335-
basename, ext = os.path.splitext(fname)
336-
if basename.endswith('-failed-diff'):
337-
path = os.path.join(root, fname)
338-
entry = Entry(path, result_images, source)
339-
entries.append(entry)
340-
entries.sort(key=lambda x: x.name)
341-
return entries
332+
return sorted(
333+
(Entry(path, result_images, source)
334+
for path in Path(result_images).glob("**/*-failed-diff.*")),
335+
key=lambda x: x.name)
342336

343337

344338
def launch(result_images, source):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.