From 4836a24924eb5864aa6f8d210159416278854f08 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sat, 9 Jul 2016 14:46:28 -0400 Subject: [PATCH 1/2] STY: whitespace changes --- lib/matplotlib/font_manager.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index 87a5239e7ca9..5f2c9880761c 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -562,8 +562,10 @@ def createFontList(fontfiles, fontext='ttf'): for fpath in fontfiles: verbose.report('createFontDict: %s' % (fpath), 'debug') fname = os.path.split(fpath)[1] - if fname in seen: continue - else: seen[fname] = 1 + if fname in seen: + continue + else: + seen[fname] = 1 if fontext == 'afm': try: fh = open(fpath, 'rb') @@ -576,7 +578,7 @@ def createFontList(fontfiles, fontext='ttf'): finally: fh.close() except RuntimeError: - verbose.report("Could not parse font file %s"%fpath) + verbose.report("Could not parse font file %s" % fpath) continue try: prop = afmFontProperty(fpath, font) @@ -586,11 +588,11 @@ def createFontList(fontfiles, fontext='ttf'): try: font = ft2font.FT2Font(fpath) except RuntimeError: - verbose.report("Could not open font file %s"%fpath) + verbose.report("Could not open font file %s" % fpath) continue except UnicodeError: verbose.report("Cannot handle unicode filenames") - #print >> sys.stderr, 'Bad file is', fpath + # print >> sys.stderr, 'Bad file is', fpath continue try: prop = ttfFontProperty(font) @@ -600,6 +602,7 @@ def createFontList(fontfiles, fontext='ttf'): fontlist.append(prop) return fontlist + class FontProperties(object): """ A class for storing and manipulating font properties. From 6828691a6d71d3f91493d32de24b36fda0c905a7 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Sat, 9 Jul 2016 14:46:39 -0400 Subject: [PATCH 2/2] FIX: catch ValueError as well Closes #6702 Extension of #5233 --- lib/matplotlib/font_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index 5f2c9880761c..7c0de740dc9a 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -596,7 +596,7 @@ def createFontList(fontfiles, fontext='ttf'): continue try: prop = ttfFontProperty(font) - except (KeyError, RuntimeError): + except (KeyError, RuntimeError, ValueError): continue fontlist.append(prop)