-
-
Notifications
You must be signed in to change notification settings - Fork 29
Add ZimFileReader and ZimFileArticle implementation and tests #16
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
Conversation
mgautierfr
left a comment
There was a problem hiding this comment.
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.
libzim/libzim.pyx
Outdated
| cdef Blob blob = self.c_article.getData(<int> 0) | ||
| data = blob.data()[:blob.size()] | ||
| return data |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
tests/test_libzim_file_reader.py
Outdated
| self.zim_test_query = u"Einstein" | ||
|
|
||
| # Zim reader | ||
| self.zim_reader = ZimFileReader(self.zim_file_path) |
There was a problem hiding this comment.
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:
....
There was a problem hiding this comment.
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__() ?
b6cc1fe to
f9d850b
Compare
The reading part is in the `reader` submodule.
No description provided.