@@ -494,7 +494,7 @@ def get_text_blocks(
494494 blocks = tp .extractBLOCKS ()
495495 if textpage is None :
496496 del tp
497- if sort is True :
497+ if sort :
498498 blocks .sort (key = lambda b : (b [3 ], b [0 ]))
499499 return blocks
500500
@@ -571,7 +571,7 @@ def sort_words(words):
571571
572572 if textpage is None :
573573 del tp
574- if words and sort is True :
574+ if words and sort :
575575 # advanced sort if any words found
576576 words = sort_words (words )
577577
@@ -771,7 +771,7 @@ def full_ocr(page, dpi, language, flags):
771771 return tpage
772772
773773 # if OCR for the full page, OCR its pixmap @ desired dpi
774- if full is True :
774+ if full :
775775 return full_ocr (page , dpi , language , flags )
776776
777777 # For partial OCR, make a normal textpage, then extend it with text that
@@ -948,7 +948,7 @@ def get_text(
948948 page , clip = clip , flags = flags , textpage = textpage , sort = sort
949949 )
950950
951- if option == "text" and sort is True :
951+ if option == "text" and sort :
952952 return get_sorted_text (
953953 page ,
954954 clip = clip ,
@@ -1227,7 +1227,7 @@ def recurse(olItem, liste, lvl):
12271227 lvl = 1
12281228 liste = []
12291229 toc = recurse (olItem , liste , lvl )
1230- if doc .is_pdf and simple is False :
1230+ if doc .is_pdf and not simple :
12311231 doc ._extend_toc_items (toc )
12321232 return toc
12331233
@@ -4561,7 +4561,7 @@ def remove_hidden(cont_lines):
45614561 if doc .is_encrypted or doc .is_closed :
45624562 raise ValueError ("closed or encrypted doc" )
45634563
4564- if clean_pages is False :
4564+ if not clean_pages :
45654565 hidden_text = False
45664566 redactions = False
45674567
@@ -4848,9 +4848,11 @@ def output_justify(start, line):
48484848 nlines = len (new_lines )
48494849 if nlines > max_lines :
48504850 msg = "Only fitting %i of %i lines." % (max_lines , nlines )
4851- if warn is True :
4851+ if warn is None :
4852+ pass
4853+ elif warn :
48524854 pymupdf .message ("Warning: " + msg )
4853- elif warn is False :
4855+ else :
48544856 raise ValueError (msg )
48554857
48564858 start = pymupdf .Point ()
@@ -5561,7 +5563,7 @@ def subset_fonts(doc: pymupdf.Document, verbose: bool = False, fallback: bool =
55615563 # Once the sets of used unicodes and glyphs are known, we compute a
55625564 # smaller version of the buffer user package fontTools.
55635565
5564- if fallback is False : # by default use MuPDF function
5566+ if not fallback : # by default use MuPDF function
55655567 pdf = mupdf .pdf_document_from_fz_document (doc )
55665568 mupdf .pdf_subset_fonts2 (pdf , list (range (doc .page_count )))
55675569 return
0 commit comments