Skip to content

Commit

Permalink
STY: Small increase of readability (#2974)
Browse files Browse the repository at this point in the history
Using enumerate more in PdfWriter.
  • Loading branch information
j-t-1 authored Dec 2, 2024
1 parent 3e01345 commit a6c9d36
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,24 +1435,24 @@ def write(self, stream: Union[Path, StrByteType]) -> Tuple[bool, IO[Any]]:

def list_objects_in_increment(self) -> List[IndirectObject]:
"""
For debugging/analysis.
Provides the list of new/modified objects that will be written
For analysis or debugging.
Provides the list of new or modified objects that will be written
in the increment.
Deleted objects will not be freed but will become orphans.
Returns:
List of (new / modified) IndirectObjects
List of new or modified IndirectObjects
"""
original_hash_count = len(self._original_hash)
return [
cast(IndirectObject, self._objects[i]).indirect_reference
for i in range(len(self._objects))
cast(IndirectObject, obj).indirect_reference
for i, obj in enumerate(self._objects)
if (
self._objects[i] is not None
obj is not None
and (
i >= len(self._original_hash)
or cast(PdfObject, self._objects[i]).hash_bin()
!= self._original_hash[i]
i >= original_hash_count
or obj.hash_bin() != self._original_hash[i]
)
)
]
Expand All @@ -1462,11 +1462,11 @@ def _write_increment(self, stream: StreamType) -> None:
object_blocks = []
current_start = -1
current_stop = -2
original_hash_count = len(self._original_hash)
for i, obj in enumerate(self._objects):
if self._objects[i] is not None and (
i >= len(self._original_hash)
or cast(PdfObject, self._objects[i]).hash_bin()
!= self._original_hash[i]
if obj is not None and (
i >= original_hash_count
or obj.hash_bin() != self._original_hash[i]
):
idnum = i + 1
assert isinstance(obj, PdfObject) # mypy
Expand Down

0 comments on commit a6c9d36

Please sign in to comment.