Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STY: Increase readability slightly #3178

Merged
merged 3 commits into from
Mar 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions pypdf/generic/_image_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def extract_inline_AHx(stream: StreamType) -> bytes:
raise PdfReadError("Unexpected end of stream")
pos_tok = data_buffered.find(b">")
if pos_tok >= 0: # found >
data_out += data_buffered[: (pos_tok + 1)]
data_out += data_buffered[: pos_tok + 1]
stream.seek(-len(data_buffered) + pos_tok + 1, 1)
break
pos_ei = data_buffered.find(b"EI")
Expand All @@ -69,17 +69,17 @@ def extract_inline_AHx(stream: StreamType) -> bytes:
pos_ei -= 1
data_out += data_buffered[:pos_ei]
break
elif len(data_buffered) == 2:
if len(data_buffered) == 2:
data_out += data_buffered
raise PdfReadError("Unexpected end of stream")
else: # > nor EI found
data_out += data_buffered[:-2]
stream.seek(-2, 1)
# Neither > nor EI found
data_out += data_buffered[:-2]
stream.seek(-2, 1)

ei_tok = read_non_whitespace(stream)
ei_tok += stream.read(2)
stream.seek(-3, 1)
if ei_tok[0:2] != b"EI" or not (ei_tok[2:3] == b"" or ei_tok[2:3] in WHITESPACES):
if ei_tok[:2] != b"EI" or not (ei_tok[2:3] == b"" or ei_tok[2:3] in WHITESPACES):
raise PdfReadError("EI stream not found")
return data_out

Expand All @@ -101,7 +101,7 @@ def extract_inline_A85(stream: StreamType) -> bytes:
data_out += data_buffered[: pos_tok + 2]
stream.seek(-len(data_buffered) + pos_tok + 2, 1)
break
elif len(data_buffered) == 2: # end of buffer
if len(data_buffered) == 2: # end of buffer
data_out += data_buffered
raise PdfReadError("Unexpected end of stream")
data_out += data_buffered[
Expand All @@ -112,7 +112,7 @@ def extract_inline_A85(stream: StreamType) -> bytes:
ei_tok = read_non_whitespace(stream)
ei_tok += stream.read(2)
stream.seek(-3, 1)
if ei_tok[0:2] != b"EI" or not (ei_tok[2:3] == b"" or ei_tok[2:3] in WHITESPACES):
if ei_tok[:2] != b"EI" or not (ei_tok[2:3] == b"" or ei_tok[2:3] in WHITESPACES):
raise PdfReadError("EI stream not found")
return data_out

Expand All @@ -139,7 +139,7 @@ def extract_inline_RL(stream: StreamType) -> bytes:
ei_tok = read_non_whitespace(stream)
ei_tok += stream.read(2)
stream.seek(-3, 1)
if ei_tok[0:2] != b"EI" or not (ei_tok[2:3] == b"" or ei_tok[2:3] in WHITESPACES):
if ei_tok[:2] != b"EI" or not (ei_tok[2:3] == b"" or ei_tok[2:3] in WHITESPACES):
raise PdfReadError("EI stream not found")
return data_out

Expand Down Expand Up @@ -183,7 +183,7 @@ def extract_inline_DCT(stream: StreamType) -> bytes:
ei_tok = read_non_whitespace(stream)
ei_tok += stream.read(2)
stream.seek(-3, 1)
if ei_tok[0:2] != b"EI" or not (ei_tok[2:3] == b"" or ei_tok[2:3] in WHITESPACES):
if ei_tok[:2] != b"EI" or not (ei_tok[2:3] == b"" or ei_tok[2:3] in WHITESPACES):
raise PdfReadError("EI stream not found")
return data_out

Expand Down
Loading