From fab69256741b1b025d305f536941e71e21b9f1e0 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Fri, 27 Oct 2023 11:29:12 +0200 Subject: [PATCH] use new snake_case naming for pymupdf 1.23.0 and later closes: #6 --- plakativ.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/plakativ.py b/plakativ.py index 81e7add..a2f0109 100755 --- a/plakativ.py +++ b/plakativ.py @@ -712,7 +712,11 @@ class Plakativ: shape = page.new_shape() else: shape = page.newShape() - shape.drawRect( + if hasattr(shape, "draw_rect"): + dr = shape.draw_rect + else: + dr = shape.drawRect + dr( fitz.Rect( x0, y0, @@ -722,7 +726,7 @@ class Plakativ: ) shape.finish(color=(0, 0, 1)) # outer rectangle - shape.drawRect( + dr( fitz.Rect( x0 - left, y0 - top, @@ -816,9 +820,13 @@ class Plakativ: shape = page.new_shape() else: shape = page.newShape() + if hasattr(shape, "draw_rect"): + dr = shape.draw_rect + else: + dr = shape.drawRect if guides: if portrait: - shape.drawRect( + dr( fitz.Rect( mm_to_pt(self.layout["border_left"]), mm_to_pt(self.layout["border_top"]), @@ -827,7 +835,7 @@ class Plakativ: ) ) else: - shape.drawRect( + dr( fitz.Rect( mm_to_pt(self.layout["border_bottom"]), mm_to_pt(self.layout["border_left"]), @@ -863,7 +871,7 @@ class Plakativ: ) if border: if portrait: - shape.drawRect( + dr( fitz.Rect( mm_to_pt(self.layout["border_left"] - x), mm_to_pt(self.layout["border_top"] - y), @@ -880,7 +888,7 @@ class Plakativ: ) ) else: - shape.drawRect( + dr( fitz.Rect( mm_to_pt(self.layout["border_bottom"] - x), mm_to_pt(self.layout["border_left"] - y),