Skip to content

Commit 465a453

Browse files
tacaswellkahnchana
authored andcommitted
STY: pep8 cleanup
1 parent 03bacb8 commit 465a453

File tree

1 file changed

+35
-19
lines changed

1 file changed

+35
-19
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,39 +1068,46 @@ def write(self, *kl, **kwargs):
10681068
else:
10691069
creator_str = "matplotlib version " + __version__ + \
10701070
", http://matplotlib.org/"
1071+
10711072
def print_figure_impl():
10721073
# write the PostScript headers
1073-
if isEPSF: print("%!PS-Adobe-3.0 EPSF-3.0", file=fh)
1074-
else: print("%!PS-Adobe-3.0", file=fh)
1075-
if title: print("%%Title: "+title, file=fh)
1074+
if isEPSF:
1075+
print("%!PS-Adobe-3.0 EPSF-3.0", file=fh)
1076+
else:
1077+
print("%!PS-Adobe-3.0", file=fh)
1078+
if title:
1079+
print("%%Title: "+title, file=fh)
10761080
print("%%Creator: " + creator_str, file=fh)
10771081
# get source date from SOURCE_DATE_EPOCH, if set
10781082
# See https://reproducible-builds.org/specs/source-date-epoch/
10791083
source_date_epoch = os.getenv("SOURCE_DATE_EPOCH")
10801084
if source_date_epoch:
10811085
source_date = datetime.datetime.utcfromtimestamp(
1082-
int(source_date_epoch) ).strftime("%a %b %d %H:%M:%S %Y")
1086+
int(source_date_epoch)).strftime("%a %b %d %H:%M:%S %Y")
10831087
else:
10841088
source_date = time.ctime()
10851089
print("%%CreationDate: "+source_date, file=fh)
10861090
print("%%Orientation: " + orientation, file=fh)
1087-
if not isEPSF: print("%%DocumentPaperSizes: "+papertype, file=fh)
1091+
if not isEPSF:
1092+
print("%%DocumentPaperSizes: "+papertype, file=fh)
10881093
print("%%%%BoundingBox: %d %d %d %d" % bbox, file=fh)
1089-
if not isEPSF: print("%%Pages: 1", file=fh)
1094+
if not isEPSF:
1095+
print("%%Pages: 1", file=fh)
10901096
print("%%EndComments", file=fh)
10911097

10921098
Ndict = len(psDefs)
10931099
print("%%BeginProlog", file=fh)
10941100
if not rcParams['ps.useafm']:
10951101
Ndict += len(ps_renderer.used_characters)
1096-
print("/mpldict %d dict def"%Ndict, file=fh)
1102+
print("/mpldict %d dict def" % Ndict, file=fh)
10971103
print("mpldict begin", file=fh)
10981104
for d in psDefs:
1099-
d=d.strip()
1105+
d = d.strip()
11001106
for l in d.split('\n'):
11011107
print(l.strip(), file=fh)
11021108
if not rcParams['ps.useafm']:
1103-
for font_filename, chars in six.itervalues(ps_renderer.used_characters):
1109+
for font_filename, chars in six.itervalues(
1110+
ps_renderer.used_characters):
11041111
if len(chars):
11051112
font = get_font(font_filename)
11061113
glyph_ids = []
@@ -1120,21 +1127,29 @@ def print_figure_impl():
11201127
# STIX fonts). This will simply turn that off to avoid
11211128
# errors.
11221129
if is_opentype_cff_font(font_filename):
1123-
raise RuntimeError("OpenType CFF fonts can not be saved using the internal Postscript backend at this time.\nConsider using the Cairo backend.")
1130+
msg = ("OpenType CFF fonts can not be saved "
1131+
"using the internal Postscript backend "
1132+
"at this time.\nConsider using the "
1133+
"Cairo backend.")
1134+
raise RuntimeError(msg)
11241135
else:
11251136
fh.flush()
11261137
convert_ttf_to_ps(
1127-
font_filename.encode(sys.getfilesystemencoding()),
1138+
font_filename.encode(
1139+
sys.getfilesystemencoding()),
11281140
fh, fonttype, glyph_ids)
11291141
print("end", file=fh)
11301142
print("%%EndProlog", file=fh)
11311143

1132-
if not isEPSF: print("%%Page: 1 1", file=fh)
1144+
if not isEPSF:
1145+
print("%%Page: 1 1", file=fh)
11331146
print("mpldict begin", file=fh)
1134-
#print >>fh, "gsave"
1135-
print("%s translate"%_nums_to_str(xo, yo), file=fh)
1136-
if rotation: print("%d rotate"%rotation, file=fh)
1137-
print("%s clipbox"%_nums_to_str(width*72, height*72, 0, 0), file=fh)
1147+
1148+
print("%s translate" % _nums_to_str(xo, yo), file=fh)
1149+
if rotation:
1150+
print("%d rotate" % rotation, file=fh)
1151+
print("%s clipbox" % _nums_to_str(width*72, height*72, 0, 0),
1152+
file=fh)
11381153

11391154
# write the figure
11401155
content = self._pswriter.getvalue()
@@ -1143,10 +1158,10 @@ def print_figure_impl():
11431158
print(content, file=fh)
11441159

11451160
# write the trailer
1146-
#print >>fh, "grestore"
11471161
print("end", file=fh)
11481162
print("showpage", file=fh)
1149-
if not isEPSF: print("%%EOF", file=fh)
1163+
if not isEPSF:
1164+
print("%%EOF", file=fh)
11501165
fh.flush()
11511166

11521167
if rcParams['ps.usedistiller']:
@@ -1161,8 +1176,9 @@ def print_figure_impl():
11611176
requires_unicode = file_requires_unicode(outfile)
11621177

11631178
if (not requires_unicode and
1164-
(six.PY3 or not isinstance(outfile, StringIO))):
1179+
(six.PY3 or not isinstance(outfile, StringIO))):
11651180
fh = io.TextIOWrapper(outfile, encoding="latin-1")
1181+
11661182
# Prevent the io.TextIOWrapper from closing the
11671183
# underlying file
11681184
def do_nothing():

0 commit comments

Comments
 (0)