-
Notifications
You must be signed in to change notification settings - Fork 147
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
Added jmespath to selector #27
Conversation
Current coverage is
|
I have no idea why the pypy tests are failing |
Hi @voith, all the test cases alone worth the work IMO. I scheduled it to review over the weekend. thanks! |
some notes from my quck look:
|
@dangra I will try to incorporate your suggestions in my next commit. |
Hey @dangra, I guess you forgot to review this pull. You said you'd review it on the last weekend. |
Its been more than a month since this pull has been opened. Is there any chance of getting this reviewed?? It's sad that I put in so much effort on this PR and it looks like a waste now! |
Hello @voith, it's definitely not a waste -- even when a PR is not accepted, this is how discussions evolve. Please have a little patience, we'll get to it. 👍 |
@eliasdorneles Thanks for saying that! Makes me feel much better :) |
This PR implements addition of
jmespath
to parselSelector
as discussed in #25.I have tried to implement @dangra's suggestion of having nested selectors. The
jmespath
returns a flattenedSelectorList
instance.Examples
example of nested selector methods over
html
containingjson
example of nested selector methods over
json
containinghtml
Design Considerations
type=json
, text is tried to be decoded into a valid json object. Incase of failure the selector silently re initializes to the default type i.ehtml
xpath
andjson
and vice versa, a new selector instance is created for translating the required data types.json
. egremove_namespaces
.Some Side Notes
extract
method to outputunicode
. But I'm not entirely sure about what I've implemented is right. Some help here will be appreciated.In the above cases jmespath returned
None
when queried for a jsonnull
and also for a non- existent jmespath. So ideally, for the first case theextract
method should returnu'null'
andNone
in the second case. But I couldn't think of a way to distinguish the two.So I converted this json to equivalent xml and tested the xpath on it. The selector returned
None
.So I decided to go with the same. This implementation of jmespath returns
None
instead ofnull
in either of the two cases.3. I have tried to match existing test cases for equivalent jmespath. But for testcase
test_null_bytes_shouldnt_raise_errors
I didn't know what was the right thing to do. In my case,json.loads
is unable to decode such strings and so get silently converted to typehtml
.4. I've not updated the docs right now. I'll update them only if the maintainers would like to merge this PR!
PS : I'm open for suggestions and modifications this pull might need before getting merged!