Skip to content

Commit 843acc0

Browse files
committed
Add search through single child element
Based on home-assistant/core#135914 (comment)
1 parent eb3dc9f commit 843acc0

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/python_picnic_api2/helper.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
last = "└── "
1010

1111
IMAGE_SIZES = ["small", "medium", "regular", "large", "extra-large"]
12-
IMAGE_BASE_URL = (
13-
"https://storefront-prod.nl.picnicinternational.com/static/images"
14-
)
12+
IMAGE_BASE_URL = "https://storefront-prod.nl.picnicinternational.com/static/images"
1513

1614
SOLE_ARTICLE_ID_PATTERN = re.compile(r'"sole_article_id":"(\w+)"')
1715

@@ -95,10 +93,7 @@ def find_articles(node):
9593
return
9694

9795
content = node.get("content", {})
98-
if (
99-
content.get("type") == "SELLING_UNIT_TILE"
100-
and "sellingUnit" in content
101-
):
96+
if content.get("type") == "SELLING_UNIT_TILE" and "sellingUnit" in content:
10297
selling_unit = content["sellingUnit"]
10398
sole_article_ids = SOLE_ARTICLE_ID_PATTERN.findall(json.dumps(node))
10499
sole_article_id = sole_article_ids[0] if sole_article_ids else None
@@ -111,6 +106,9 @@ def find_articles(node):
111106
for child in node.get("children", []):
112107
find_articles(child)
113108

109+
if "child" in node:
110+
find_articles(node.get("child"))
111+
114112
body = raw_results.get("body", {})
115113
find_articles(body.get("child", {}))
116114

0 commit comments

Comments
 (0)