aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-08-15 14:41:24 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-08-15 20:10:36 +0200
commit9f727745797a433de70f491ef7997016bb57ee04 (patch)
tree209d8491737426bda9b5c709fdbae90e9729e609 /tools
parent27bacca72da59b990bbf5bb48497825da7458d9c (diff)
snippets_translate: Fix indented conditions
Adapt the regexes accordingly. Pick-to: 6.3 6.2 Fixes: PYSIDE-2030 Change-Id: I6515b2ca0fe23c753feadeb491173b72889abba5 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/snippets_translate/handlers.py6
-rw-r--r--tools/snippets_translate/tests/test_converter.py1
2 files changed, 4 insertions, 3 deletions
diff --git a/tools/snippets_translate/handlers.py b/tools/snippets_translate/handlers.py
index b3a827699..0e0508a4f 100644
--- a/tools/snippets_translate/handlers.py
+++ b/tools/snippets_translate/handlers.py
@@ -7,9 +7,9 @@ import sys
from parse_utils import (dstrip, get_indent, get_qt_module_class,
parse_arguments, remove_ref, replace_main_commas)
-IF_PATTERN = re.compile(r'^if\s*\(')
-ELSE_IF_PATTERN = re.compile(r'^}?\s*else if\s*\(')
-WHILE_PATTERN = re.compile(r'^while\s*\(')
+IF_PATTERN = re.compile(r'^\s*if\s*\(')
+ELSE_IF_PATTERN = re.compile(r'^\s*}?\s*else if\s*\(')
+WHILE_PATTERN = re.compile(r'^\s*while\s*\(')
def handle_condition(x, name):
diff --git a/tools/snippets_translate/tests/test_converter.py b/tools/snippets_translate/tests/test_converter.py
index be46e0c0b..ced52d26a 100644
--- a/tools/snippets_translate/tests/test_converter.py
+++ b/tools/snippets_translate/tests/test_converter.py
@@ -42,6 +42,7 @@ def test_and_or():
def test_while_if_elseif():
assert st("while(a)") == "while a:"
assert st("if (condition){") == "if condition:"
+ assert st(" if (condition){") == " if condition:"
assert st("} else if (a) {") == " elif a:"
assert (
st("if (!m_vbo.isCreated()) // init() failed,")