Skip to content

Commit

Permalink
Changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Nykakin committed Aug 26, 2024
1 parent d625705 commit 12cb8ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 4 additions & 0 deletions tests/test_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ def breadcrumbs(self):
[
(None, None),
("", None),
(" ", None),
("foo", Brand(name="foo")),
(" foo ", Brand(name="foo")),
(Selector(text="<html></html>"), None),
(SelectorList([]), None),
(fromstring("<p>foo</p>"), Brand(name="foo")),
Expand Down Expand Up @@ -401,6 +403,8 @@ def images(self):
({}, {}),
(22.9, "22.90"),
(22.0, "22.00"),
("22.9", "22.9"),
("Do not apply to strings...", "Do not apply to strings..."),
],
)
def test_prices(input_value, expected_value):
Expand Down
8 changes: 1 addition & 7 deletions zyte_common_items/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def brand_processor(value: Any, page: Any) -> Any:
value = _handle_selectorlist(value)

if isinstance(value, str):
value = value.strip()
return Brand(name=value) if value else None

if isinstance(value, (Selector, SelectorList, HtmlElement)):
Expand Down Expand Up @@ -373,13 +374,6 @@ def images_processor(value: Any, page: Any) -> Any:
Other inputs are returned unchanged.
"""

# TODO: add generic-purpose extract_images utility to zyte-parsers
#
# value = _handle_selectorlist(value)
# if isinstance(value, (Selector, HtmlElement)):
# images = extract_images(value)
# return [Image(url=url) for url in images]

if isinstance(value, str):
return [Image(url=value)]

Expand Down

0 comments on commit 12cb8ef

Please sign in to comment.