made bs4 and soupsieve standalone in this project

This commit is contained in:
2025-04-24 19:26:20 +02:00
parent aefb27614f
commit 3dd7b5a18d
17 changed files with 68 additions and 62 deletions

View File

@ -194,13 +194,19 @@ def get_image_size(fhandle, pathlike):
fhandle.seek(size, 1)
byte = fhandle.read(1)
if byte == b"":
fhandle = end
byte = fhandle.read(1)
# Reached end of file unexpectedly, break the loop
break
while ord(byte) == 0xFF:
byte = fhandle.read(1)
if byte == b"": # Check EOF in inner loop too
break
if byte == b"": # Break outer loop if inner loop hit EOF
break
ftype = ord(byte)
size = struct.unpack(">H", fhandle.read(2))[0] - 2
# Check if the loop exited because of a break (EOF) before finding the marker
if not (0xC0 <= ftype <= 0xCF):
return "unknown format {!r}".format(format_)
# We are at a SOFn block
fhandle.seek(1, 1) # Skip `precision' byte.
height, width = struct.unpack(">HH", fhandle.read(4))