Skip to content

Commit 087eae4

Browse files
committed
fix:1.blockly logic modules add parentheses
1 parent dcff99e commit 087eae4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

xarm/tools/blockly/_blockly_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def __get_logic_compare(self, block, arg_map=None):
228228
cond_a = self._get_condition_expression(values[0], arg_map=arg_map)
229229
if len(values) > 1:
230230
cond_b = self._get_condition_expression(values[1], arg_map=arg_map)
231-
return '{} {} {}'.format(cond_a, op, cond_b)
231+
return '({}) {} ({})'.format(cond_a, op, cond_b)
232232

233233
def __get_logic_operation(self, block, arg_map=None):
234234
op = self._get_node('field', block).text.lower()
@@ -239,7 +239,7 @@ def __get_logic_operation(self, block, arg_map=None):
239239
cond_a = self._get_condition_expression(values[0], arg_map=arg_map)
240240
if len(values) > 1:
241241
cond_b = self._get_condition_expression(values[1], arg_map=arg_map)
242-
return '{} {} {}'.format(cond_a, op, cond_b)
242+
return '({}) {} ({})'.format(cond_a, op, cond_b)
243243

244244
def __get_math_arithmetic(self, block, arg_map=None):
245245
field = self._get_node('field', block).text

xarm/tools/blockly/_blockly_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ def _handle_python_code(self, block, indent=0, arg_map=None, **kwargs):
11191119
prev_is_empty = False
11201120
if (self._is_exec or (not self._is_exec and not self._is_ide)) and code.strip() and code not in \
11211121
['finally:', 'else:'] and all([i not in code for i in ['elif', 'except', 'def', 'class']]) \
1122-
and not code.startswith('@')::
1122+
and not code.startswith('@'):
11231123
code_indent = re.match('(\s*).*', code).group(1)
11241124
self._append_main_code(code_indent + 'if not self.is_alive:', indent + 2)
11251125
self._append_main_code(code_indent + 'return', indent + 3)

0 commit comments

Comments
 (0)