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

Wrap indexData #149

Merged
merged 4 commits into from
Sep 26, 2022
Merged

Wrap indexData #149

merged 4 commits into from
Sep 26, 2022

Conversation

mgautierfr
Copy link
Collaborator

@mgautierfr mgautierfr commented Jul 6, 2022

Fixes #92

@codecov
Copy link

codecov bot commented Jul 6, 2022

Codecov Report

Base: 96.88% // Head: 92.87% // Decreases project coverage by -4.00% ⚠️

Coverage data is based on head (a649a61) compared to base (66dac18).
Patch coverage: 58.33% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #149      +/-   ##
==========================================
- Coverage   96.88%   92.87%   -4.01%     
==========================================
  Files           1        1              
  Lines         417      463      +46     
==========================================
+ Hits          404      430      +26     
- Misses         13       33      +20     
Impacted Files Coverage Δ
libzim/libzim.pyx 92.87% <58.33%> (-4.01%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

libzim/libzim.pyx Outdated Show resolved Hide resolved
@mgautierfr
Copy link
Collaborator Author

BTW, I'm not sure of the best casing.
get_indexdata, get_indexData, get_index_data ?
get_wordcount, get_word_count, get_wordCount, get_wordscount ?

@rgaudin
Copy link
Member

rgaudin commented Jul 7, 2022

BTW, I'm not sure of the best casing. get_indexdata, get_indexData, get_index_data ? get_wordcount, get_word_count, get_wordCount, get_wordscount ?

Ah I was wondering also what would be the most self-explanatory.

I'd suggest: get_indexdata, get_wordcount, get_geoposition and so on but any of them makes sense so you should go with what you feel is more appropriate.

@mgautierfr mgautierfr force-pushed the indexData branch 2 times, most recently from de9e334 to 1e2f56b Compare July 11, 2022 12:24
@mgautierfr
Copy link
Collaborator Author

I'd suggest: get_indexdata, get_wordcount, get_geoposition and so on but any of them makes sense so you should go with what you feel is more appropriate.

It is what I've used. So we are good. I let you merge if you are ok with the PR

@rgaudin rgaudin self-requested a review July 11, 2022 15:40
Copy link
Member

@rgaudin rgaudin left a comment

Choose a reason for hiding this comment

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

Looks good but any exception in the IndexData methods ends up crashing the process. All the _cy_call_fct functions do enter the except block and set the trackeback in error[0] but for some reason it crashes instead of forwarding it up

tests/test_libzim_creator.py::test_exc_in_indexdata
[DEBUG] inside has_indexdata()
[DEBUG] captured exception: Some User Exception
[DEBUG] error[0]= b'Traceback (most recent call last):\n  File "libzim/libzim.pyx", line 148, in libzim.bool_cy_call_fct\n    return call_method(obj, method)\n  File "libzim/libzim.pyx", line 84, in libzim.call_method\n    return func()\n  File "/Users/reg/src/pylibzim/tests/test_libzim_creator.py", line 698, in has_indexdata\n    raise IOError("Some User Exception")\nOSError: Some User Exception\n'
libc++abi: terminating with uncaught exception of type std::runtime_error: Traceback (most recent call last):
  File "libzim/libzim.pyx", line 148, in libzim.bool_cy_call_fct
    return call_method(obj, method)
  File "libzim/libzim.pyx", line 84, in libzim.call_method
    return func()
  File "/Users/reg/src/pylibzim/tests/test_libzim_creator.py", line 698, in has_indexdata
    raise IOError("Some User Exception")
OSError: Some User Exception

Fatal Python error: Aborted

@@ -87,6 +87,13 @@ cdef object call_method(object obj, string method):
# object to the correct cpp type.
# Will be used by cpp side to call python method.
cdef public api:
bool obj_has_attribute(object obj, string attribute) with gil:
"""Check if a object has a given attribute"""
attr = getattr(obj, attribute.decode('UTF-8'), None)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason for not using hasattr?

@kelson42
Copy link
Contributor

Code coverage has dropped significantly. A bit of automated testing might be welcome.

@stale
Copy link

stale bot commented Aug 13, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.

@stale stale bot added the stale label Aug 13, 2022
@kelson42
Copy link
Contributor

@mgautierfr Please finish this Pr.

@stale stale bot removed the stale label Aug 13, 2022
@mgautierfr
Copy link
Collaborator Author

Looks good but any exception in the IndexData methods ends up crashing the process. All the _cy_call_fct functions do enter the except block and set the trackeback in error[0] but for some reason it crashes instead of forwarding it up

This is more related to #42 than wrapping IndexData. I have a working version which need changes in python-libzim and libzim itself. I will create PRs soon.

@rgaudin
Copy link
Member

rgaudin commented Sep 26, 2022

As discussed, merging this despite the error handling issue and coverage.

@rgaudin rgaudin merged commit 4641f5a into master Sep 26, 2022
@rgaudin rgaudin deleted the indexData branch September 26, 2022 11:56
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.

Support getIndexData
3 participants