aboutsummaryrefslogtreecommitdiffstats
path: root/tools/snippets_translate
diff options
context:
space:
mode:
Diffstat (limited to 'tools/snippets_translate')
-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,")