fix: Listen in der Tagesuebersicht und Katalog-Makros uebernehmen
Tagebuchzeilen mit Liste gelten als zugeordnet. Berechnete Zutaten-Makros lassen sich am Tag in nutrition_log schreiben. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
44e3e216ab
commit
95453d548a
10 files changed
+221
-28
No files matched your search
@@ -10,6 +10,10 @@ LEADING_QTY_RE = re.compile(
|
||||
r"^\s*\d+(?:[.,]\d+)?\s*(?:g|kg|ml|l|stück|stk|st\.?|portion(?:en)?)\b[\s,.:\-–]*",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
TRAILING_QTY_RE = re.compile(
|
||||
r"[\s,.:\-–]+\d+(?:[.,]\d+)?\s*(?:g|kg|ml|l)\s*$",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
MULTISPACE_RE = re.compile(r"\s+")
|
||||
DECIMAL_IN_NAME_RE = re.compile(r"(\d),(\d)")
|
||||
|
||||
@@ -27,8 +31,10 @@ def normalize_food_name(raw: str | None) -> str:
|
||||
s = strip_leading_quantity(raw)
|
||||
if not s:
|
||||
return ""
|
||||
s = TRAILING_QTY_RE.sub("", s)
|
||||
s = s.replace("-", " ")
|
||||
s = DECIMAL_IN_NAME_RE.sub(r"\1.\2", s)
|
||||
return s.lower()
|
||||
return MULTISPACE_RE.sub(" ", s).strip().lower()
|
||||
|
||||
|
||||
def item_name_keys(raw: str | None, stored_norm: str | None = None) -> set[str]:
|
||||
|
||||
Reference in new issue
Block a user