[#341] procedure._serialize_action should also support strings.

This commit is contained in:
Fabio Manganiello 2024-09-13 18:21:27 +02:00
parent 853fce2521
commit 771e32e368
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 7 additions and 5 deletions

View file

@ -284,7 +284,7 @@ class ProceduresPlugin(RunnablePlugin, ProcedureEntityManager):
return re.sub(r'[^\w.]+', '_', (name or '').strip(' .')) return re.sub(r'[^\w.]+', '_', (name or '').strip(' .'))
@classmethod @classmethod
def _serialize_action(cls, data: Union[Iterable, Dict]) -> Union[Dict, List]: def _serialize_action(cls, data: Union[Iterable, Dict]) -> Union[Dict, List, str]:
if isinstance(data, dict): if isinstance(data, dict):
name = data.get('action', data.get('name')) name = data.get('action', data.get('name'))
if name: if name:
@ -301,6 +301,8 @@ class ProceduresPlugin(RunnablePlugin, ProcedureEntityManager):
) )
for k, v in data.items() for k, v in data.items()
} }
elif isinstance(data, str):
return data
else: else:
return [cls._serialize_action(item) for item in data if item is not None] return [cls._serialize_action(item) for item in data if item is not None]

View file

@ -281,7 +281,7 @@ class Procedure:
if request.type in [StatementType.BREAK, StatementType.CONTINUE]: if request.type in [StatementType.BREAK, StatementType.CONTINUE]:
loop = self._find_nearest_loop(__stack__) loop = self._find_nearest_loop(__stack__)
if request == StatementType.BREAK: if request.type == StatementType.BREAK:
loop._should_break = True # pylint: disable=protected-access loop._should_break = True # pylint: disable=protected-access
else: else:
loop._should_continue = True # pylint: disable=protected-access loop._should_continue = True # pylint: disable=protected-access
@ -291,9 +291,9 @@ class Procedure:
should_break = getattr(self, '_should_break', False) should_break = getattr(self, '_should_break', False)
if isinstance(self, LoopProcedure) and (should_continue or should_break): if isinstance(self, LoopProcedure) and (should_continue or should_break):
if should_continue: if should_continue:
self._should_continue = ( # pylint: disable=attribute-defined-outside-init setattr(self, '_should_continue', False) # noqa[B010]
False else:
) setattr(self, '_should_break', False) # noqa[B010]
break break