Skip to content

Commit 3e75ffb

Browse files
Merge pull request #433 from AutomationSolutionz/if-else
[Fix] if else log improve and new syntax logic fix
2 parents e08a1e0 + 3b998a5 commit 3e75ffb

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

Framework/Built_In_Automation/Sequential_Actions/sequential_actions.py

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -364,29 +364,38 @@ def check_operators():
364364
return
365365

366366
try:
367-
if eval(left[len(statement):], sr.shared_variables):
368-
if not condition_matched:
369-
condition_matched = True
370-
for i in get_data_set_nums(right):
371-
next_level_step_data.append(i)
372-
outer_skip += next_level_step_data
373-
else:
374-
outer_skip += get_data_set_nums(right)
367+
if eval(left[len(statement):], sr.shared_variables) and not condition_matched:
368+
condition_matched = True
369+
for i in get_data_set_nums(right):
370+
next_level_step_data.append(i)
371+
outer_skip += next_level_step_data
372+
else:
373+
outer_skip += get_data_set_nums(right)
375374
except SyntaxError as e:
376375
if CommonUtil.debug_status:
377-
m = traceback.format_exc()
378-
m = m.split('except SyntaxError as e:')[-1]
379-
m = m[m.find('\n')+1:]
380-
m = m.split('SyntaxError: invalid syntax')[0]
376+
original = data_set_for_log[row_index][0]
377+
spaces = sorted([i for i in [original.find('%|'), original.find(operator)] if i != -1][:2])
378+
wrong = f" {original}\n {' ' * spaces[0]}^^"
379+
if len(spaces) == 2:
380+
wrong += f"{' ' * (spaces[1] - spaces[0] - 2)}^^"
381381

382-
correct = left.replace(operator, operator[1:-1]) if operator else left
382+
correct = original.replace(operator, operator[1:-1]) if operator else left
383383
correct = correct.replace('%|', '').replace('|%', '')
384384
correct = statement + correct[len(statement):]
385385

386+
true = re.findall('==\s*True', correct)
387+
if len(true) > 0:
388+
for i in true:
389+
correct_2 = correct.replace(i, "")
390+
try:
391+
if eval(correct[len(statement):], sr.shared_variables) == eval(correct_2[len(statement):], sr.shared_variables):
392+
correct = correct_2
393+
except:
394+
pass
386395
CommonUtil.ExecLog(
387396
sModuleInfo,
388-
m+f"Syntax error. Correct form would be >> {correct}\nPlease migrate all if_else actions to this new dataset that is exactly similar to python syntax. Previous dataset is deprecated",
389-
3,
397+
f"{wrong}\nSyntax error. Correction:\n {correct}\nPlease migrate all if_else actions to this new dataset that is exactly similar to python syntax. Previous dataset is deprecated",
398+
2,
390399
)
391400
if operator == "|==|":
392401
if Lvalue == Rvalue and not condition_matched:

0 commit comments

Comments
 (0)