Skip to content

Commit 0c8a0bc

Browse files
src/__init__.py: simplified some bool tests.
1 parent b0011aa commit 0c8a0bc

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/__init__.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4513,7 +4513,7 @@ def get_page_fonts(self, pno: int, full: bool =False) -> list:
45134513
exception_info()
45144514
raise ValueError("need a Page or page number")
45154515
val = self._getPageInfo(pno, 1)
4516-
if full is False:
4516+
if not full:
45174517
return [v[:-1] for v in val]
45184518
return val
45194519

@@ -4525,7 +4525,7 @@ def get_page_images(self, pno: int, full: bool =False) -> list:
45254525
if not self.is_pdf:
45264526
return ()
45274527
val = self._getPageInfo(pno, 2)
4528-
if full is False:
4528+
if not full:
45294529
return [v[:-1] for v in val]
45304530
return val
45314531

@@ -6720,7 +6720,7 @@ def __bool__(self):
67206720
def __eq__(self, mat):
67216721
if not hasattr(mat, "__len__"):
67226722
return False
6723-
return len(mat) == 6 and bool(self - mat) is False
6723+
return len(mat) == 6 and not (self - mat)
67246724

67256725
def __getitem__(self, i):
67266726
return (self.a, self.b, self.c, self.d, self.e, self.f)[i]
@@ -9277,7 +9277,7 @@ def get_image_bbox(self, name, transform=0):
92779277
else:
92789278
raise ValueError("found multiple images named '%s'." % name)
92799279
xref = item[-1]
9280-
if xref != 0 or transform is True:
9280+
if xref != 0 or transform:
92819281
try:
92829282
return self.get_image_rects(item, transform=transform)[0]
92839283
except Exception:
@@ -10646,7 +10646,7 @@ def __bool__(self):
1064610646
def __eq__(self, p):
1064710647
if not hasattr(p, "__len__"):
1064810648
return False
10649-
return len(p) == 2 and bool(self - p) is False
10649+
return len(p) == 2 and not (self - p)
1065010650

1065110651
def __getitem__(self, i):
1065210652
return (self.x, self.y)[i]
@@ -10677,7 +10677,7 @@ def __init__(self, *args, x=None, y=None):
1067710677
self.x = l.x
1067810678
self.y = l.y
1067910679
else:
10680-
if hasattr(l, "__getitem__") is False:
10680+
if not hasattr(l, "__getitem__"):
1068110681
raise ValueError("Point: bad args")
1068210682
if len(l) != 2:
1068310683
raise ValueError("Point: bad seq len")
@@ -10891,7 +10891,7 @@ def __init__(self, *args, ul=None, ur=None, ll=None, lr=None):
1089110891
if isinstance(l, mupdf.FzQuad):
1089210892
self.this = l
1089310893
self.ul, self.ur, self.ll, self.lr = Point(l.ul), Point(l.ur), Point(l.ll), Point(l.lr)
10894-
elif hasattr(l, "__getitem__") is False:
10894+
elif not hasattr(l, "__getitem__"):
1089510895
raise ValueError("Quad: bad args")
1089610896
elif len(l) != 4:
1089710897
raise ValueError("Quad: bad seq len")
@@ -11092,7 +11092,7 @@ def __contains__(self, x):
1109211092
def __eq__(self, rect):
1109311093
if not hasattr(rect, "__len__"):
1109411094
return False
11095-
return len(rect) == 4 and bool(self - rect) is False
11095+
return len(rect) == 4 and not (self - rect)
1109611096

1109711097
def __getitem__(self, i):
1109811098
return (self.x0, self.y0, self.x1, self.y1)[i]
@@ -12593,7 +12593,7 @@ def extractDICT(self, cb=None, sort=False) -> dict:
1259312593
if cb is not None:
1259412594
val["width"] = cb.width
1259512595
val["height"] = cb.height
12596-
if sort is True:
12596+
if sort:
1259712597
blocks = val["blocks"]
1259812598
blocks.sort(key=lambda b: (b["bbox"][3], b["bbox"][0]))
1259912599
val["blocks"] = blocks
@@ -12659,7 +12659,7 @@ def default(self, s):
1265912659
if cb is not None:
1266012660
val["width"] = cb.width
1266112661
val["height"] = cb.height
12662-
if sort is True:
12662+
if sort:
1266312663
blocks = val["blocks"]
1266412664
blocks.sort(key=lambda b: (b["bbox"][3], b["bbox"][0]))
1266512665
val["blocks"] = blocks
@@ -12673,7 +12673,7 @@ def extractRAWDICT(self, cb=None, sort=False) -> dict:
1267312673
if cb is not None:
1267412674
val["width"] = cb.width
1267512675
val["height"] = cb.height
12676-
if sort is True:
12676+
if sort:
1267712677
blocks = val["blocks"]
1267812678
blocks.sort(key=lambda b: (b["bbox"][3], b["bbox"][0]))
1267912679
val["blocks"] = blocks
@@ -12693,7 +12693,7 @@ def default(self,s):
1269312693
if cb is not None:
1269412694
val["width"] = cb.width
1269512695
val["height"] = cb.height
12696-
if sort is True:
12696+
if sort:
1269712697
blocks = val["blocks"]
1269812698
blocks.sort(key=lambda b: (b["bbox"][3], b["bbox"][0]))
1269912699
val["blocks"] = blocks
@@ -12708,7 +12708,7 @@ def extractSelection(self, pointa, pointb):
1270812708

1270912709
def extractText(self, sort=False) -> str:
1271012710
"""Return simple, bare text on the page."""
12711-
if sort is False:
12711+
if not sort:
1271212712
return self._extractText(0)
1271312713
blocks = self.extractBLOCKS()[:]
1271412714
blocks.sort(key=lambda b: (b[3], b[0]))

0 commit comments

Comments
 (0)