From 132815496cb1a8cfc2287efb7a697a53db799b4a Mon Sep 17 00:00:00 2001 From: smilerz Date: Mon, 24 Apr 2023 11:58:21 -0500 Subject: [PATCH] create Transpose Words automation --- cookbook/helper/ingredient_parser.py | 6 ++++++ cookbook/migrations/0189_alter_automation_type_and_more.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cookbook/helper/ingredient_parser.py b/cookbook/helper/ingredient_parser.py index 57b70f44c..29df8c54f 100644 --- a/cookbook/helper/ingredient_parser.py +++ b/cookbook/helper/ingredient_parser.py @@ -274,6 +274,10 @@ class IngredientParser: return: new ingredient string """ + #################################################### + #################################################### + #################################################### + #################################################### if self.ignore_rules: return ingredient @@ -309,6 +313,8 @@ class IngredientParser: if len(ingredient) == 0: raise ValueError('string to parse cannot be empty') + ingredient = self.apply_transpose_words_automations(ingredient) + # some people/languages put amount and unit at the end of the ingredient string # if something like this is detected move it to the beginning so the parser can handle it if len(ingredient) < 1000 and re.search(r'^([^\W\d_])+(.)*[1-9](\d)*\s*([^\W\d_])+', ingredient): diff --git a/cookbook/migrations/0189_alter_automation_type_and_more.py b/cookbook/migrations/0189_alter_automation_type_and_more.py index a0aca2ed5..8bc9d3ef3 100644 --- a/cookbook/migrations/0189_alter_automation_type_and_more.py +++ b/cookbook/migrations/0189_alter_automation_type_and_more.py @@ -1,4 +1,4 @@ -# Generated by Django 4.1.7 on 2023-04-24 15:00 +# Generated by Django 4.1.7 on 2023-04-24 16:22 from django.db import migrations, models