Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e02a3b

Browse files
committed
Update from MPL code review
1 parent 27e2eb1 commit 6e02a3b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/matplotlib/fontconfig_pattern.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,15 @@ def _property(self, s, loc, tokens):
178178

179179

180180
def _escape_val(val, escape_func):
181-
if type(val) == list:
181+
"""
182+
Given a string value or a list of string values, run each value through
183+
the input escape function to make the values into legal font config
184+
strings. The result is returned as a string.
185+
"""
186+
if isinstance(val, list):
182187
val = [escape_func(r'\\\1', str(x)) for x in val
183188
if x is not None]
184-
if val != []:
185-
val = ','.join(val)
189+
val = ','.join(val)
186190
else:
187191
val = escape_func(r'\\\1', str(val))
188192

@@ -199,7 +203,7 @@ def generate_fontconfig_pattern(d):
199203
# Family is added first w/o a keyword
200204
family = d.get_family()
201205
if family is not None and family != []:
202-
props.append("%s" % (_escape_val(family, family_escape)))
206+
props.append(_escape_val(family, family_escape))
203207

204208
# The other keys are added as key=value
205209
for key in ['style', 'variant', 'weight', 'stretch', 'file', 'size']:

0 commit comments

Comments
 (0)