8000 Allow to pass custom Creator to images created with ps backend · matplotlib/matplotlib@80b2361 · GitHub
[go: up one dir, main page]

Skip to content

Commit 80b2361

Browse files
Xarthisiusnewville
authored andcommitted
Allow to pass custom Creator to images created with ps backend
1 parent 15999fe commit 80b2361

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,13 +1059,19 @@ def write(self, *kl, **kwargs):
10591059
self.figure.set_facecolor(origfacecolor)
10601060
self.figure.set_edgecolor(origedgecolor)
10611061

1062+
# check for custom metadata
1063+
metadata = kwargs.pop("metadata", None)
1064+
if metadata is not None and 'Creator' in metadata:
1065+
creator_str = metadata['Creator']
1066+
else:
1067+
creator_str = "matplotlib version " + __version__ + \
1068+
", http://matplotlib.org/"
10621069
def print_figure_impl():
10631070
# write the PostScript headers
10641071
if isEPSF: print("%!PS-Adobe-3.0 EPSF-3.0", file=fh)
10651072
else: print("%!PS-Adobe-3.0", file=fh)
10661073
if title: print("%%Title: "+title, file=fh)
1067-
print(("%%Creator: matplotlib version "
1068-
+__version__+", http://matplotlib.org/"), file=fh)
1074+
print("%%Creator: " + creator_str, file=fh)
10691075
# get source date from SOURCE_DATE_EPOCH, if set
10701076
# See https://reproducible-builds.org/specs/source-date-epoch/
10711077
source_date_epoch = os.getenv("SOURCE_DATE_EPOCH")
@@ -1249,12 +1255,21 @@ def write(self, *kl, **kwargs):
12491255
self.figure.set_facecolor(origfacecolor)
12501256
self.figure.set_edgecolor(origedgecolor)
12511257

1258+
# check for custom metadata
1259+
metadata = kwargs.pop("metadata", None)
1260+
if metadata is not None and 'Creator' in metadata:
1261+
creator_str = metadata['Creator']
1262+
else:
1263+
creator_str = "matplotlib version " + __version__ + \
1264+
", http://matplotlib.org/"
1265+
12521266
# write to a temp file, we'll move it to outfile when done
12531267
fd, tmpfile = mkstemp()
12541268
with io.open(fd, 'w', encoding='latin-1') as fh:
12551269
# write the Encapsulated PostScript headers
12561270
print("%!PS-Adobe-3.0 EPSF-3.0", file=fh)
12571271
if title: print("%%Title: "+title, file=fh)
1272+
<<<<<<< d8cac234387c1bc50b4686b9568b4f5e43149957
12581273
print(("%%Creator: matplotlib version "
12591274
+__version__+", http://matplotlib.org/"), file=fh)
12601275
# get source date from SOURCE_DATE_EPOCH, if set
@@ -1266,6 +1281,10 @@ def write(self, *kl, **kwargs):
12661281
else:
12671282
source_date = time.ctime()
12681283
print("%%CreationDate: "+source_date, file=fh)
1284+
=======
1285+
print("%%Creator: " + creator_str, file=fh)
1286+
print("%%CreationDate: "+time.ctime(time.time()), file=fh)
1287+
>>>>>>> Allow to pass custom Creator to images created with ps backend
12691288
print("%%%%BoundingBox: %d %d %d %d" % bbox, file=fh)
12701289
print("%%EndComments", file=fh)
12711290

0 commit comments

Comments
 (0)
0