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

Accept file objects #99

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

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