1414import contextlib
1515import logging
1616import os
17+ from pathlib import Path
1718import re
1819import warnings
1920
@@ -53,6 +54,7 @@ def _remove_blacklisted_style_params(d, warn=True):
5354 return o
5455
5556
57+ @cbook .deprecated ("3.2" )
5658def is_style_file (filename ):
5759 """Return True if the filename looks like a style file."""
5860 return STYLE_FILE_PATTERN .match (filename ) is not None
@@ -167,6 +169,7 @@ def update_user_library(library):
167169 return library
168170
169171
172+ @cbook .deprecated ("3.2" )
170173def iter_style_files (style_dir ):
171174 """Yield file path and name of styles in the given directory."""
172175 for path in os .listdir (style_dir ):
@@ -178,17 +181,14 @@ def iter_style_files(style_dir):
178181
179182
180183def read_style_directory (style_dir ):
181- """Return dictionary of styles defined in ` style_dir` ."""
184+ """Return dictionary of styles defined in * style_dir* ."""
182185 styles = dict ()
183- for path , name in iter_style_files (style_dir ):
186+ for path in Path (style_dir ). glob ( f"*. { STYLE_EXTENSION } " ):
184187 with warnings .catch_warnings (record = True ) as warns :
185- styles [name ] = rc_params_from_file (path ,
186- use_default_template = False )
187-
188+ styles [path .stem ] = rc_params_from_file (
189+ path , use_default_template = False )
188190 for w in warns :
189- message = 'In %s: %s' % (path , w .message )
190- _log .warning (message )
191-
191+ _log .warning ('In %s: %s' , path , w .message )
192192 return styles
193193
194194
0 commit comments