8000 Update helper.py · codesalatdev/python-picnic-api@aa6ca40 · GitHub
[go: up one dir, main page]

Skip to content

Commit aa6ca40

Browse files
authored
Update helper.py
1 parent 2612a2d commit aa6ca40

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

python_picnic_api/helper.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,29 +82,6 @@ def get_image(id: str, size="regular", suffix="webp"):
8282
assert size in sizes, "size must be one of: " + ", ".join(sizes)
8383
return f"{IMAGE_BASE_URL}/{id}/{size}.{suffix}"
8484

85-
86-
def _extract_search_results(raw_results: Dict[str, Any]) -> List[Dict[str, Any]]:
87-
"""Extract search results from a nested dictionary structure returned by Picnic search."""
88-
search_results = []
89-
90-
for section in raw_results.get("body", {}).get("children", []):
91-
for item in section.get("children", []):
92-
content = item.get("content", {})
93-
if "selling_unit" in content:
94-
sole_article_ids = SOLE_ARTICLE_ID_PATTERN.findall(
95-
json.dumps(item.get("pml", {}))
96-
)
97-
sole_article_id = sole_article_ids[0] if sole_article_ids else None
98-
99-
result_entry = {
100-
**content["selling_unit"],
101-
"sole_article_id": sole_article_id,
102-
}
103-
search_results.append(result_entry)
104-
105-
return search_results
106-
107-
10885
def _extract_search_results(raw_results, max_items: int = 10):
10986
"""Extract search results from the nested dictionary structure returned by Picnic search.
11087
Number of max items can be defined to reduce excessive nested search"""

0 commit comments

Comments
 (0)
0