Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Support JMESPath now #181
Support JMESPath now #181
Changes from 33 commits
63af8c5
ddc8e73
17f14d5
4590544
6151e3b
546fcc9
0a70390
85c7b58
3846ea7
2741727
9235304
03289a6
ecf37b8
c731c35
24cf915
9508f0e
fe44a3d
d84e957
5a57a3c
8ad0330
b01f5a1
ca3bc23
15c9118
344d4df
fa7c32e
7fe4d5e
3f9b779
f7cd122
58f5b77
a01ebfb
4e3ce0f
aba3c40
ed9e2b5
9cceac2
bb4f994
d0c98b7
50e18e7
ccf6b63
8a10f23
9e22492
2da08ea
5f03cea
fa25f75
06ffdc3
f854cc0
ca14d63
2465f4e
918089c
f0d42d3
72e7b3c
51042ca
f6a316c
5954e79
f6e59ce
c1c98f0
b374384
6b60a8b
98daa08
84751de
ef5a6ea
475bdf5
33e8d38
2e3b633
654fb26
6226397
6780a06
e1c6838
aa803c7
2efc71d
3b74896
b6f1e3a
5034df0
835458c
6b1729b
54065be
f6f3bf9
497ecba
045ad12
3c81e3f
b424483
276cf9f
8fe06ce
ccc7abb
a86ca2b
be8dbb3
fa2085e
a68fecf
05cec44
b53e71f
4349ce4
14d17fd
470a31b
5f98857
305306f
01a4fb2
1c519d9
3c00325
cf8a693
ecce282
58dedc2
8895fd7
f4d19de
599cc79
c75723b
39cdad3
69a8517
d000b54
7536aeb
321a3d1
bddbc6d
d20b4ba
e9d5ada
812b2bf
c7f53d4
746a0da
ff8e946
bd0ad80
0fcff9a
10b78a8
dd0a4c9
c69e0c6
64569a7
7232241
3b3ec90
9f18a37
53d5146
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
"text" is also supported; is it intentional that we don't document it? I also wonder if there is a better terminology available than "selector type", though no suggestions :)
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.
I believe it is on purpose.
"text"
is meant to be an interim value until a more specific value can be determined. If you are setting thetype
parameter to begin with, you should set it to the right, more-specific value or not set it at all. Maybe we could letself.type
beNone
instead of"text"
, I don‘t recall if there was a technical reason to do otherwise.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.
I still don't get the benefit of the type as a user argument. The selector is a wrapper that has its logic figured out by which methods it uses and which data it finds per query. Allowing the user to set the type (besides purely for backward compatibility) seems to only allow it to break if this config was done poorly by the user. Without it, the Selector will either work or not depending purely on the methods used (unless I am missing out on something).
After saying that, I would say I don't find the
"text"
type worth documenting and if @Gallaecio idea of just letting it beNone
has no pending technical issues, then we should remove"text"
altogether.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.
After fiddling a bit with the code again, I believe
"text"
is needed, becauseNone
needs to imply one of"html"
or"xml"
for backward compatibility. But I still would not document it for the reasons I explained in my earlier comment, i.e. is not meant for users to use.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.
Should we preserve base_url somewhere, so that if html is loaded from jmespath, base_url is applied?
TBH, I'm not exactly sure why base_url is needed, but if it's needed, it'd be better to have it consistent.
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.
I'm fine with not fixing it in this PR though.
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.
Yes, since it looks like a problem (if it is one) in the original code as well, it may be best to address it separately.
Also, from the lxml docs:
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 do you think about renaming type from
json
to something likedata
? json is an encoding/decoding format; I expected self.root to be a json-encoded string after seeing type="json". But actuallyjson
means that self.root contains some arbitraty Python object.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.
To me it would be a bit like renaming "html" and "xml" to "etree".
self.type
does not represent the format after parsing, but the format before parsing, even if the input data is provided pre-parsed. And arbitrary data is not supported either, if your data has non-JSON structures chances are you are getting some error at some point, e.g. when using JMESPath.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.
I wonder if code would be simpler if we remove
type="text"
, and usetype="json"
for these cases as well.if self.type == "text"
would be replaced withself.type == "json" and insinstance(self.root, str)
. Not 100% sure about it, but there are signs that we can do it.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.
#181 (comment)