parsel icon indicating copy to clipboard operation
parsel copied to clipboard

Support JSONPath

Open deepakdinesh1123 opened this issue 3 years ago • 5 comments
trafficstars

Support for JSONPath has been added with the jsonpath-ng library. Most of the implementation is based on #181 which adds support for json using the JMESPath library.

closes #204

deepakdinesh1123 avatar Mar 13 '22 11:03 deepakdinesh1123

Codecov Report

Merging #237 (302b80b) into master (f5f73d3) will decrease coverage by 0.61%. The diff coverage is 96.77%.

@@             Coverage Diff             @@
##            master     #237      +/-   ##
===========================================
- Coverage   100.00%   99.38%   -0.62%     
===========================================
  Files            5        5              
  Lines          290      327      +37     
  Branches        59       72      +13     
===========================================
+ Hits           290      325      +35     
- Misses           0        1       +1     
- Partials         0        1       +1     
Impacted Files Coverage Δ
parsel/selector.py 98.94% <96.55%> (-1.06%) :arrow_down:
parsel/csstranslator.py 100.00% <100.00%> (ø)
parsel/xpathfuncs.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update f5f73d3...302b80b. Read the comment docs.

codecov[bot] avatar Mar 15 '22 08:03 codecov[bot]

I have included jsonpath_ng in setup.py but flake8 is throwing an error saying that jsonpath_ng not found. How do I resolve it?

deepakdinesh1123 avatar Mar 16 '22 07:03 deepakdinesh1123

The flake errors, if you look at lines 71-74 of the CI output, is:

/home/runner/work/parsel/parsel/docs/conf.py:87:5: E128 continuation line under-indented for visual indent
/home/runner/work/parsel/parsel/docs/conf.py:88:5: E128 continuation line under-indented for visual indent
/home/runner/work/parsel/parsel/docs/conf.py:98:5: E128 continuation line under-indented for visual indent
/home/runner/work/parsel/parsel/docs/conf.py:99:5: E128 continuation line under-indented for visual indent

I suggest you run black docs/conf.py to address it. And it would be great if you could modify https://github.com/scrapy/parsel/blob/master/tox.ini#L42 to include the docs folder among the black default arguments.

Gallaecio avatar Mar 16 '22 08:03 Gallaecio

After reformatting docs/conf.py using black, flake8 is failing with line too long error, I was not able to catch this error while running tox locally, as flake8 fails with the following error ERROR - ModuleNotFoundError: No module named 'jsonpath_ng'.

deepakdinesh1123 avatar Mar 18 '22 11:03 deepakdinesh1123

I believe you need to run black setting the line limit to 79 to comply with flake8:

black --line-length=79 …

We probably did not hit this issue in the rest of the code by pure luck, but we need to edit tox.ini to specify that length as well, otherwise later executions of black will break the length again.

As for the module error when running tox, since it works in CI, my guess is that you need to recreate your Tox environment, i.e. include --recreate in your tox command once per environment (or just once if you run all environments at once).

Gallaecio avatar Mar 21 '22 12:03 Gallaecio