Refactor:book parser use with to handle bytesIO (#11800)

### What problem does this PR solve?

book parser use with to handle bytesIO

### Type of change

- [x] Refactoring
This commit is contained in:
Stephen Hu
2025-12-08 10:18:46 +08:00
committed by GitHub
parent 4d7934061e
commit b66881a371

View File

@ -143,6 +143,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
elif re.search(r"\.doc$", filename, re.IGNORECASE):
callback(0.1, "Start to parse.")
with BytesIO(binary) as binary:
binary = BytesIO(binary)
doc_parsed = parser.from_buffer(binary)
sections = doc_parsed['content'].split('\n')