Skip to content

Conversation

@AT0myks
Copy link
Contributor

@AT0myks AT0myks commented Dec 2, 2024

This gives more flexibility when using ubireader as a library and fixes the behavior mentioned in #89 (comment).

For example this is now possible:

with ZipFile("ubi.zip") as myzip:
    with myzip.open("ubi.bin") as ubi:
        block_size = guess_peb_size(ubi)
        ufile_obj = ubi_file(ubi, block_size)
        ...

Admittedly this is not the best use case right now if you need walk.index() because it takes an extremely long time when the file is zipped, but that's a separate issue.

@qkaiser qkaiser self-requested a review December 3, 2024 08:32
For functions that work on UBI files and call
`open()`, additionally allow a file object to be
passed, and in that case leave the responsibility
of closing it to the caller. This means that the
scripts can now open the file once instead of two
to four times previously.
@qkaiser
Copy link
Contributor

qkaiser commented Dec 3, 2024

This looks decent but I'll wait for my more Python experienced colleagues to have a look :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants