mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-08 05:55:35 -04:00
fix: HTML/JSON import failing (#7330)
This commit is contained in:
@@ -1,3 +1,23 @@
|
||||
import json
|
||||
|
||||
|
||||
class MatchAny:
|
||||
def __eq__(self, _: object) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def parse_sse_events(text: str) -> list[dict]:
|
||||
"""Parse SSE response text into a list of events with 'event' and 'data' keys."""
|
||||
events = []
|
||||
current: dict = {}
|
||||
for line in text.splitlines():
|
||||
if line.startswith("event:"):
|
||||
current["event"] = line[len("event:") :].strip()
|
||||
elif line.startswith("data:"):
|
||||
current["data"] = json.loads(line[len("data:") :].strip())
|
||||
elif line == "" and current:
|
||||
events.append(current)
|
||||
current = {}
|
||||
if current:
|
||||
events.append(current)
|
||||
return events
|
||||
|
||||
Reference in New Issue
Block a user