@@ -116,6 +116,7 @@ def __init__(
116
116
) -> None :
117
117
self .strict = strict
118
118
self .flattened_pages : Optional [List [PageObject ]] = None
119
+
119
120
#: Storage of parsed PDF objects.
120
121
self .resolved_objects : Dict [Tuple [Any , Any ], Optional [PdfObject ]] = {}
121
122
@@ -430,7 +431,7 @@ def get_object(
430
431
idnum = - 1
431
432
generation = - 1 # exception will be raised below
432
433
if idnum != indirect_reference .idnum and self .xref_index :
433
- # Xref table probably had bad indexes due to not being zero-indexed
434
+ # xref table probably had bad indexes due to not being zero-indexed
434
435
if self .strict :
435
436
raise PdfReadError (
436
437
f"Expected object ID ({ indirect_reference .idnum } { indirect_reference .generation } ) "
@@ -441,9 +442,8 @@ def get_object(
441
442
elif idnum != indirect_reference .idnum and self .strict :
442
443
# some other problem
443
444
raise PdfReadError (
444
- f"Expected object ID ({ indirect_reference .idnum } "
445
- f"{ indirect_reference .generation } ) does not match actual "
446
- f"({ idnum } { generation } )."
445
+ f"Expected object ID ({ indirect_reference .idnum } { indirect_reference .generation } ) "
446
+ f"does not match actual ({ idnum } { generation } )."
447
447
)
448
448
if self .strict :
449
449
assert generation == indirect_reference .generation
@@ -511,7 +511,7 @@ def get_object(
511
511
def read_object_header (self , stream : StreamType ) -> Tuple [int , int ]:
512
512
# Should never be necessary to read out whitespace, since the
513
513
# cross-reference table should put us in the right spot to read the
514
- # object header. In reality some files have stupid cross reference
514
+ # object header. In reality some files have stupid cross- reference
515
515
# tables that are off by whitespace bytes.
516
516
extra = False
517
517
skip_over_comment (stream )
@@ -558,7 +558,7 @@ def cache_indirect_object(
558
558
return obj
559
559
560
560
def _replace_object (self , indirect : IndirectObject , obj : PdfObject ) -> PdfObject :
561
- # function reserved for future dev
561
+ # function reserved for future development
562
562
if indirect .pdf != self :
563
563
raise ValueError ("Cannot update PdfReader with external object" )
564
564
if (indirect .generation , indirect .idnum ) not in self .resolved_objects :
@@ -580,14 +580,14 @@ def read(self, stream: StreamType) -> None:
580
580
startxref = self ._find_startxref_pos (stream )
581
581
self ._startxref = startxref
582
582
583
- # check and eventually correct the startxref only in not strict
583
+ # check and eventually correct the startxref only if not strict
584
584
xref_issue_nr = self ._get_xref_issues (stream , startxref )
585
585
if xref_issue_nr != 0 :
586
586
if self .strict and xref_issue_nr :
587
587
raise PdfReadError ("Broken xref table" )
588
588
logger_warning (f"incorrect startxref pointer({ xref_issue_nr } )" , __name__ )
589
589
590
- # read all cross reference tables and their trailers
590
+ # read all cross- reference tables and their trailers
591
591
self ._read_xref_tables_and_trailers (stream , startxref , xref_issue_nr )
592
592
593
593
# if not zero-indexed, verify that the table is correct; change it if necessary
@@ -598,7 +598,7 @@ def read(self, stream: StreamType) -> None:
598
598
continue
599
599
xref_k = sorted (
600
600
xref_entry .keys ()
601
- ) # must ensure ascendant to prevent damage
601
+ ) # ensure ascending to prevent damage
602
602
for id in xref_k :
603
603
stream .seek (xref_entry [id ], 0 )
604
604
try :
@@ -962,8 +962,8 @@ def _read_pdf15_xref_stream(
962
962
assert cast (str , xrefstream ["/Type" ]) == "/XRef"
963
963
self .cache_indirect_object (generation , idnum , xrefstream )
964
964
stream_data = BytesIO (xrefstream .get_data ())
965
- # Index pairs specify the subsections in the dictionary. If
966
- # none create one subsection that spans everything.
965
+ # Index pairs specify the subsections in the dictionary.
966
+ # If none, create one subsection that spans everything.
967
967
idx_pairs = xrefstream .get ("/Index" , [0 , xrefstream .get ("/Size" )])
968
968
entry_sizes = cast (Dict [Any , Any ], xrefstream .get ("/W" ))
969
969
assert len (entry_sizes ) >= 3
@@ -1067,7 +1067,7 @@ def _rebuild_xref_table(self, stream: StreamType) -> None:
1067
1067
f" whereas { o .get ('/N' )} expected" ,
1068
1068
__name__ ,
1069
1069
)
1070
- except Exception : # could be of many cause
1070
+ except Exception : # could be multiple causes
1071
1071
pass
1072
1072
1073
1073
stream .seek (0 , 0 )
@@ -1174,7 +1174,7 @@ def add_form_topname(self, name: str) -> Optional[DictionaryObject]:
1174
1174
return None
1175
1175
acroform = cast (DictionaryObject , catalog [NameObject ("/AcroForm" )])
1176
1176
if "/Fields" not in acroform :
1177
- # TODO: : No error returns but may be extended for XFA Forms
1177
+ # TODO: No error but this may be extended for XFA Forms
1178
1178
return None
1179
1179
1180
1180
interim = DictionaryObject ()
0 commit comments