Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions itemloaders/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Item Loader

See documentation in docs/topics/loaders.rst
See documentation in :ref:`declaring-loaders`.
"""

from __future__ import annotations
Expand Down Expand Up @@ -624,6 +624,6 @@ def _get_jmesvalues(self, jmess: str | Iterable[str]) -> list[Any]:
jmess = arg_to_iter(jmess)
if not hasattr(self.selector, "jmespath"):
raise AttributeError(
"Please install parsel >= 1.8.1 to get jmespath support"
"Please install parsel >= 1.8.1 to get JMESPath support"
)
return flatten(self.selector.jmespath(jmes).getall() for jmes in jmess)
18 changes: 11 additions & 7 deletions itemloaders/processors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
This module provides some commonly used processors for Item Loaders.

See documentation in docs/topics/loaders.rst
See documentation in :ref:`declaring-loaders`.
"""

from __future__ import annotations
Expand Down Expand Up @@ -185,9 +185,13 @@ def __call__(self, values: Any) -> Any:

class SelectJmes:
"""
Query the input string for the jmespath (given at instantiation), and return the answer
Requires : jmespath(https://github.com/jmespath/jmespath)
Note: SelectJmes accepts only one input element at a time.
Query the input string for a *JMESPath* expression (given at instantiation), and return the answer.

*Requires*: `JMESPath <https://github.com/jmespath/jmespath>`__

.. note::

``SelectJmes`` accepts only one input element at a time.

Example:

Expand All @@ -198,7 +202,7 @@ class SelectJmes:
>>> proc({'foo': {'bar': 'baz'}})
{'bar': 'baz'}

Working with Json:
Working with JSON:

>>> import json
>>> proc_single_json_str = Compose(json.loads, SelectJmes("foo"))
Expand All @@ -218,9 +222,9 @@ def __init__(self, json_path: str):
)

def __call__(self, value: Any) -> Any:
"""Query value for the jmespath query and return answer
"""Query value for the JMESPath query and return answer
:param value: a data structure (dict, list) to extract from
:return: Element extracted according to jmespath query
:return: Element extracted according to JMESPath query
"""
return self.compiled_path.search(value)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_selector_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def test_jmes_not_installed(self):
loader.add_jmes("name", "name", re="ma")

assert (
str(err.value) == "Please install parsel >= 1.8.1 to get jmespath support"
str(err.value) == "Please install parsel >= 1.8.1 to get JMESPath support"
)

def test_add_jmes_re(self):
Expand Down