14
14
import contextlib
15
15
import logging
16
16
import os
17
+ from pathlib import Path
17
18
import re
18
19
import warnings
19
20
@@ -53,6 +54,7 @@ def _remove_blacklisted_style_params(d, warn=True):
53
54
return o
54
55
55
56
57
+ @cbook .deprecated ("3.2" )
56
58
def is_style_file (filename ):
57
59
"""Return True if the filename looks like a style file."""
58
60
return STYLE_FILE_PATTERN .match (filename ) is not None
@@ -167,6 +169,7 @@ def update_user_library(library):
167
169
return library
168
170
169
171
172
+ @cbook .deprecated ("3.2" )
170
173
def iter_style_files (style_dir ):
171
174
"""Yield file path and name of styles in the given directory."""
172
175
for path in os .listdir (style_dir ):
@@ -178,17 +181,14 @@ def iter_style_files(style_dir):
178
181
179
182
180
183
def read_style_directory (style_dir ):
181
- """Return dictionary of styles defined in ` style_dir` ."""
184
+ """Return dictionary of styles defined in * style_dir* ."""
182
185
styles = dict ()
183
- for path , name in iter_style_files (style_dir ):
186
+ for path in Path (style_dir ). glob ( f"*. { STYLE_EXTENSION } " ):
184
187
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 )
188
190
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 )
192
192
return styles
193
193
194
194
0 commit comments