Skip to content

Commit 9f53b14

Browse files
tacaswellkahnchana
authored andcommitted
STY: pep8 clean up
1 parent 710b509 commit 9f53b14

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ def _print_figure_tex(self, outfile, format, dpi, facecolor, edgecolor,
12341234
else:
12351235
raise ValueError("outfile must be a path or a file-like object")
12361236

1237-
self.figure.dpi = 72 # ignore the dpi kwarg
1237+
self.figure.dpi = 72 # ignore the dpi kwarg
12381238
width, height = self.figure.get_size_inches()
12391239
xo = 0
12401240
yo = 0
@@ -1262,18 +1262,17 @@ def write(self, *kl, **kwargs):
12621262
else:
12631263
self._pswriter = io.StringIO()
12641264

1265-
12661265
# mixed mode rendering
12671266
_bbox_inches_restore = kwargs.pop("bbox_inches_restore", None)
12681267
ps_renderer = self._renderer_class(width, height,
12691268
self._pswriter, imagedpi=dpi)
12701269
renderer = MixedModeRenderer(self.figure,
1271-
width, height, dpi, ps_renderer,
1272-
bbox_inches_restore=_bbox_inches_restore)
1270+
width, height, dpi, ps_renderer,
1271+
bbox_inches_restore=_bbox_inches_restore)
12731272

12741273
self.figure.draw(renderer)
12751274

1276-
if dryrun: # return immediately if dryrun (tightbbox=True)
1275+
if dryrun: # return immediately if dryrun (tightbbox=True)
12771276
return
12781277

12791278
self.figure.set_facecolor(origfacecolor)
@@ -1287,18 +1286,22 @@ def write(self, *kl, **kwargs):
12871286
", http://matplotlib.org/"
12881287

12891288
# write to a temp file, we'll move it to outfile when done
1289+
12901290
fd, tmpfile = mkstemp()
1291+
12911292
with io.open(fd, 'w', encoding='latin-1') as fh:
12921293
# write the Encapsulated PostScript headers
12931294
print("%!PS-Adobe-3.0 EPSF-3.0", file=fh)
1294-
if title: print("%%Title: "+title, file=fh)
1295+
if title:
1296+
print("%%Title: "+title, file=fh)
12951297
print("%%Creator: " + creator_str, file=fh)
12961298
# get source date from SOURCE_DATE_EPOCH, if set
12971299
# See https://reproducible-builds.org/specs/source-date-epoch/
12981300
source_date_epoch = os.getenv("SOURCE_DATE_EPOCH")
12991301
if source_date_epoch:
13001302
source_date = datetime.datetime.utcfromtimestamp(
1301-
int(source_date_epoch) ).strftime("%a %b %d %H:%M:%S %Y")
1303+
int(source_date_epoch)).strftime(
1304+
"%a %b %d %H:%M:%S %Y")
13021305
else:
13031306
source_date = time.ctime()
13041307
print("%%CreationDate: "+source_date, file=fh)
@@ -1307,30 +1310,29 @@ def write(self, *kl, **kwargs):
13071310

13081311
Ndict = len(psDefs)
13091312
print("%%BeginProlog", file=fh)
1310-
print("/mpldict %d dict def"%Ndict, file=fh)
1313+
print("/mpldict %d dict def" % Ndict, file=fh)
13111314
print("mpldict begin", file=fh)
13121315
for d in psDefs:
1313-
d=d.strip()
1316+
d = d.strip()
13141317
for l in d.split('\n'):
13151318
print(l.strip(), file=fh)
13161319
print("end", file=fh)
13171320
print("%%EndProlog", file=fh)
13181321

13191322
print("mpldict begin", file=fh)
1320-
#print >>fh, "gsave"
1321-
print("%s translate"%_nums_to_str(xo, yo), file=fh)
1322-
print("%s clipbox"%_nums_to_str(width*72, height*72, 0, 0), file=fh)
1323+
print("%s translate" % _nums_to_str(xo, yo), file=fh)
1324+
print("%s clipbox" % _nums_to_str(width*72, height*72, 0, 0),
1325+
file=fh)
13231326

13241327
# write the figure
13251328
print(self._pswriter.getvalue(), file=fh)
13261329

13271330
# write the trailer
1328-
#print >>fh, "grestore"
13291331
print("end", file=fh)
13301332
print("showpage", file=fh)
13311333
fh.flush()
13321334

1333-
if isLandscape: # now we are ready to rotate
1335+
if isLandscape: # now we are ready to rotate
13341336
isLandscape = True
13351337
width, height = height, width
13361338
bbox = (lly, llx, ury, urx)
@@ -1344,24 +1346,26 @@ def write(self, *kl, **kwargs):
13441346
paperWidth, paperHeight = paperHeight, paperWidth
13451347
else:
13461348
temp_papertype = _get_papertype(width, height)
1347-
if papertype=='auto':
1349+
if papertype == 'auto':
13481350
papertype = temp_papertype
13491351
paperWidth, paperHeight = papersize[temp_papertype]
13501352
else:
13511353
paperWidth, paperHeight = papersize[papertype]
1352-
if (width>paperWidth or height>paperHeight) and isEPSF:
1354+
if (width > paperWidth or height > paperHeight) and isEPSF:
13531355
paperWidth, paperHeight = papersize[temp_papertype]
1354-
verbose.report('Your figure is too big to fit on %s paper. %s \
1355-
paper will be used to prevent clipping.'%(papertype, temp_papertype), 'helpful')
1356-
1356+
verbose.report(
1357+
('Your figure is too big to fit on %s paper. %s '
1358+
'paper will be used to prevent clipping.'
1359+
) % (papertype, temp_papertype), 'helpful')
13571360

13581361
texmanager = ps_renderer.get_texmanager()
13591362
font_preamble = texmanager.get_font_preamble()
13601363
custom_preamble = texmanager.get_custom_preamble()
13611364

13621365
psfrag_rotated = convert_psfrags(tmpfile, ps_renderer.psfrag,
13631366
font_preamble,
1364-
custom_preamble, paperWidth, paperHeight,
1367+
custom_preamble, paperWidth,
1368+
paperHeight,
13651369
orientation)
13661370

13671371
if rcParams['ps.usedistiller'] == 'ghostscript':
@@ -1371,9 +1375,11 @@ def write(self, *kl, **kwargs):
13711375
xpdf_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox,
13721376
rotated=psfrag_rotated)
13731377
elif rcParams['text.usetex']:
1374-
if False: pass # for debugging
1375-
else: gs_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox,
1376-
rotated=psfrag_rotated)
1378+
if False:
1379+
pass # for debugging
1380+
else:
1381+
gs_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox,
1382+
rotated=psfrag_rotated)
13771383

13781384
if is_writable_file_like(outfile):
13791385
if file_requires_unicode(outfile):
@@ -1389,6 +1395,7 @@ def write(self, *kl, **kwargs):
13891395
shutil.move(tmpfile, outfile)
13901396
os.chmod(outfile, mode)
13911397

1398+
13921399
def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
13931400
paperWidth, paperHeight, orientation):
13941401
"""

0 commit comments

Comments
 (0)