8000 Merge pull request #22885 from anntzer/pdfop · matplotlib/matplotlib@62c4bd1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 62c4bd1

Browse files
authored
Merge pull request #22885 from anntzer/pdfop
Deprecate two-layered backend_pdf.Op enum.
2 parents 5bc10b1 + 4f6980c commit 62c4bd1

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``backend_pdf.Operator`` and ``backend_pdf.Op.op``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... are deprecated in favor of a single standard `enum.Enum` interface on
4+
`.backend_pdf.Op`.

lib/matplotlib/backends/backend_pdf.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ def pdfRepr(self):
399399
return b'/' + self.name
400400

401401

402+
@_api.deprecated("3.6")
402403
class Operator:
403-
"""PDF operator object."""
404404
__slots__ = ('op',)
405405

406406
def __init__(self, op):
@@ -422,46 +422,52 @@ def pdfRepr(self):
422422
return self._x
423423

424424

425-
# PDF operators (not an exhaustive list)
426-
class Op(Operator, Enum):
425+
class Op(Enum):
426+
"""PDF operators (not an exhaustive list)."""
427+
427428
close_fill_stroke = b'b'
428429
fill_stroke = b'B'
429430
fill = b'f'
430-
closepath = b'h',
431+
closepath = b'h'
431432
close_stroke = b's'
432433
stroke = b'S'
433434
endpath = b'n'
434-
begin_text = b'BT',
435+
begin_text = b'BT'
435436
end_text = b'ET'
436437
curveto = b'c'
437438
rectangle = b're'
438439
lineto = b'l'
439-
moveto = b'm',
440+
moveto = b'm'
440441
concat_matrix = b'cm'
441442
use_xobject = b'Do'
442-
setgray_stroke = b'G',
443+
setgray_stroke = b'G'
443444
setgray_nonstroke = b'g'
444445
setrgb_stroke = b'RG'
445-
setrgb_nonstroke = b'rg',
446+
setrgb_nonstroke = b'rg'
446447
setcolorspace_stroke = b'CS'
447-
setcolorspace_nonstroke = b'cs',
448+
setcolorspace_nonstroke = b'cs'
448449
setcolor_stroke = b'SCN'
449450
setcolor_nonstroke = b'scn'
450-
setdash = b'd',
451+
setdash = b'd'
451452
setlinejoin = b'j'
452453
setlinecap = b'J'
453454
setgstate = b'gs'
454-
gsave = b'q',
455+
gsave = b'q'
455456
grestore = b'Q'
456457
textpos = b'Td'
457458
selectfont = b'Tf'
458-
textmatrix = b'Tm',
459+
textmatrix = b'Tm'
459460
show = b'Tj'
460461
showkern = b'TJ'
461462
setlinewidth = b'w'
462463
clip = b'W'
463464
shading = b'sh'
464465

466+
op = _api.deprecated('3.6')(property(lambda self: self.value))
467+
468+
def pdfRepr(self):
469+
return self.value
470+
465471
@classmethod
466472
def paint_path(cls, fill, stroke):
467473
"""
@@ -1833,7 +1839,8 @@ def pathOperations(path, transform, clip=None, simplify=None, sketch=None):
18331839
return [Verbatim(_path.convert_to_string(
18341840
path, transform, clip, simplify, sketch,
18351841
6,
1836-
[Op.moveto.op, Op.lineto.op, b'', Op.curveto.op, Op.closepath.op],
1842+
[Op.moveto.value, Op.lineto.value, b'', Op.curveto.value,
1843+
Op.closepath.value],
18371844
True))]
18381845

18391846
def writePath(self, path, transform, clip=False, sketch=None):

0 commit comments

Comments
 (0)
0