Skip to content

Add ZimFileReader and ZimFileArticle implementation and tests - #16

Merged
mgautierfr merged 2 commits into
masterfrom
reader
May 8, 2020
Merged

mgautierfr merged 2 commits into
masterfrom
reader

Conversation

@mgautierfr

Copy link
Copy Markdown
Contributor

No description provided.

@mgautierfr mgautierfr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few things to change.
Especially about the blob.

Comment thread libzim/libzim.pyx Outdated
Comment on lines +435 to +437
cdef Blob blob = self.c_article.getData(<int> 0)
data = blob.data()[:blob.size()]
return data

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you copying the content of the blob or creating a memory view ?
If you are copying the content, you shouldn't.
If you are creating a memory view, you must keep a copy of the blob somewhere to be sure the the content pointed by the blob (and so by the memoryview) is valid.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the code is read to python to return it. What use case do you have in mind to avoid the copy?

Comment thread libzim/libzim.pyx Resolved
Comment thread run_tests.sh Resolved
Comment thread tests/test_libzim_file_reader.py Resolved
Comment thread tests/test_libzim_file_reader.py Outdated
self.zim_test_query = u"Einstein"

# Zim reader
self.zim_reader = ZimFileReader(self.zim_file_path)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line alone is not a problem. But it makes me think that it would be better to have a contextmanager for ZimFileReader:

with ZimFileReader.open(path) as zim_reader:
    ....

@jdcaballerov jdcaballerov Apr 28, 2020 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What advantages or use case do you have in mind ? What to put in __enter__() and __exit__() ?

Comment thread libzim/libzim.pyx Resolved
@mgautierfr
mgautierfr force-pushed the reader branch 2 times, most recently from b6cc1fe to f9d850b Compare May 6, 2020 08:58
@mgautierfr
mgautierfr merged commit 0df2e22 into master May 8, 2020
@mgautierfr
mgautierfr deleted the reader branch May 8, 2020 14:48
pawank925 pushed a commit to pawank925/python-libzim that referenced this pull request Oct 28, 2026
pawank925 added a commit to pawank925/python-libzim that referenced this pull request Oct 28, 2026
pawank925 added a commit to pawank925/python-libzim that referenced this pull request Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants