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

Skip to content

Commit c46525a

Browse files
authored
Merge pull request #10248 from anntzer/cleanup
Minor cleanups.
2 parents 3bb328f + 1722df9 commit c46525a

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,12 +1154,11 @@ def print_figure_impl(fh):
11541154
xpdf_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox)
11551155

11561156
if passed_in_file_object:
1157-
if file_requires_unicode(outfile):
1158-
with io.open(tmpfile, 'rb') as fh:
1159-
outfile.write(fh.read().decode('latin-1'))
1160-
else:
1161-
with io.open(tmpfile, 'rb') as fh:
1162-
outfile.write(fh.read())
1157+
fh = (io.open(tmpfile, 'r', encoding='latin-1')
1158+
if file_requires_unicode(outfile)
1159+
else io.open(tmpfile, 'rb'))
1160+
with fh:
1161+
shutil.copyfileobj(fh, outfile)
11631162
else:
11641163
with io.open(outfile, 'w') as fh:
11651164
pass
@@ -1354,12 +1353,10 @@ def write(self, *kl, **kwargs):
13541353
rotated=psfrag_rotated)
13551354

13561355
if is_writable_file_like(outfile):
1357-
if file_requires_unicode(outfile):
1358-
with io.open(tmpfile, 'rb') as fh:
1359-
outfile.write(fh.read().decode('latin-1'))
1360-
else:
1361-
with io.open(tmpfile, 'rb') as fh:
1362-
outfile.write(fh.read())
1356+
with (io.open(tmpfile, 'r', encoding='latin-1')
1357+
if file_requires_unicode(outfile)
1358+
else io.open(tmpfile, 'rb')) as fh:
1359+
shutil.copyfileobj(fh, outfile)
13631360
else:
13641361
with io.open(outfile, 'wb') as fh:
13651362
pass

lib/matplotlib/fontconfig_pattern.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88

99
# This class is defined here because it must be available in:
1010
# - The old-style config framework (:file:`rcsetup.py`)
11-
# - The traits-based config framework (:file:`mpltraits.py`)
1211
# - The font manager (:file:`font_manager.py`)
1312

14-
# It probably logically belongs in :file:`font_manager.py`, but
15-
# placing it in any of these places would have created cyclical
16-
# dependency problems, or an undesired dependency on traits even
17-
# when the traits-based config framework is not used.
13+
# It probably logically belongs in :file:`font_manager.py`, but placing it
14+
# there would have created cyclical dependency problems.
1815

1916
from __future__ import (absolute_import, division, print_function,
2017
unicode_literals)

lib/matplotlib/type1font.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def italicangle(angle):
264264
.encode('ascii'))
265265

266266
def fontmatrix(array):
267-
array = array.lstrip(b'[').rstrip(b']').strip().split()
267+
array = array.lstrip(b'[').rstrip(b']').split()
268268
array = [float(x) for x in array]
269269
oldmatrix = np.eye(3, 3)
270270
oldmatrix[0:3, 0] = array[::2]

0 commit comments

Comments
 (0)