Skip to content
Merged
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
8 changes: 8 additions & 0 deletions src/python_picnic_api2/helper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import logging
import re

# prefix components:
Expand All @@ -8,6 +9,8 @@
tee = "├── "
last = "└── "

LOGGER = logging.getLogger(__name__)

IMAGE_SIZES = ["small", "medium", "regular", "large", "extra-large"]
IMAGE_BASE_URL = "https://storefront-prod.nl.picnicinternational.com/static/images"

Expand Down Expand Up @@ -88,6 +91,8 @@
search"""
search_results = []

LOGGER.debug(f"Extracting search results from {raw_results}")

def find_articles(node):
if len(search_results) >= max_items:
return
Expand All @@ -101,6 +106,7 @@
**selling_unit,
"sole_article_id": sole_article_id,
}
LOGGER.debug(f"Found article {result_entry}")

Check warning on line 109 in src/python_picnic_api2/helper.py

View check run for this annotation

Codecov / codecov/patch

src/python_picnic_api2/helper.py#L109

Added line #L109 was not covered by tests
search_results.append(result_entry)

for child in node.get("children", []):
Expand All @@ -112,4 +118,6 @@
body = raw_results.get("body", {})
find_articles(body.get("child", {}))

LOGGER.debug(f"Found {len(search_results)}/{max_items} products after extraction")

return [{"items": search_results}]