feat: initialize market app with browsing, product, and scraping code
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled

Split from coop monolith. Includes:
- Market/browse/product blueprints
- Product sync API
- Suma scraping pipeline
- Templates for market, browse, and product views
- Dockerfile and CI workflow for independent deployment
This commit is contained in:
giles
2026-02-09 23:16:34 +00:00
commit 6271a715a1
142 changed files with 8517 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
from __future__ import annotations
import re
from typing import Optional, Tuple
def parse_price(text: str) -> Tuple[Optional[float], Optional[str], str]:
"""
Return (value, currency, raw) from a price-like string.
Supports symbols £, €, $; strips thousands commas.
"""
raw = (text or "").strip()
m = re.search(r'([£€$])?\s*([0-9][0-9.,]*)', raw)
if not m:
return None, None, raw
sym = m.group(1) or ""
num = m.group(2).replace(",", "")
try:
value = float(num)
except ValueError:
return None, None, raw
currency = {"£": "GBP", "": "EUR", "$": "USD"}.get(sym, None)
return value, currency, raw
def parse_case_size(text: str) -> Tuple[Optional[int], Optional[float], Optional[str], str]:
"""
Parse strings like "6 x 500g", "12x1L", "24 × 330 ml"
Returns (count, item_qty, item_unit, raw)
"""
raw = (text or "").strip()
if not raw:
return None, None, None, raw
t = re.sub(r"[×Xx]\s*", " x ", raw)
m = re.search(r"(\d+)\s*x\s*([0-9]*\.?[0-9]+)\s*([a-zA-Z]+)", t)
if not m:
return None, None, None, raw
count = int(m.group(1))
try:
item_qty = float(m.group(2))
except ValueError:
item_qty = None
unit = m.group(3)
return count, item_qty, unit, raw