forked from platypush/platypush
Merge branch '341/procedure-entities' into 341/procedure-entities-ui
This commit is contained in:
commit
c4610254f8
1 changed files with 10 additions and 4 deletions
|
@ -5,7 +5,7 @@ from dataclasses import dataclass
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from queue import LifoQueue
|
from queue import LifoQueue
|
||||||
from typing import Any, Optional
|
from typing import Any, List, Optional
|
||||||
|
|
||||||
from ..common import exec_wrapper
|
from ..common import exec_wrapper
|
||||||
from ..config import Config
|
from ..config import Config
|
||||||
|
@ -110,6 +110,7 @@ class Procedure:
|
||||||
for request_config in requests:
|
for request_config in requests:
|
||||||
# Check if it's a break/continue/return statement
|
# Check if it's a break/continue/return statement
|
||||||
if isinstance(request_config, str):
|
if isinstance(request_config, str):
|
||||||
|
cls._flush_if_statements(reqs, if_config)
|
||||||
reqs.append(Statement.build(request_config))
|
reqs.append(Statement.build(request_config))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -118,6 +119,7 @@ class Procedure:
|
||||||
len(request_config.keys()) == 1
|
len(request_config.keys()) == 1
|
||||||
and list(request_config.keys())[0] == 'return'
|
and list(request_config.keys())[0] == 'return'
|
||||||
):
|
):
|
||||||
|
cls._flush_if_statements(reqs, if_config)
|
||||||
reqs.append(ReturnStatement(argument=request_config['return']))
|
reqs.append(ReturnStatement(argument=request_config['return']))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -214,9 +216,7 @@ class Procedure:
|
||||||
request = Request.build(request_config)
|
request = Request.build(request_config)
|
||||||
reqs.append(request)
|
reqs.append(request)
|
||||||
|
|
||||||
while not if_config.empty():
|
cls._flush_if_statements(reqs, if_config)
|
||||||
pending_if = if_config.get()
|
|
||||||
reqs.append(IfProcedure.build(**pending_if))
|
|
||||||
|
|
||||||
return procedure_class(
|
return procedure_class(
|
||||||
name=name,
|
name=name,
|
||||||
|
@ -227,6 +227,12 @@ class Procedure:
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _flush_if_statements(requests: List, if_config: LifoQueue):
|
||||||
|
while not if_config.empty():
|
||||||
|
pending_if = if_config.get()
|
||||||
|
requests.append(IfProcedure.build(**pending_if))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _find_nearest_loop(stack):
|
def _find_nearest_loop(stack):
|
||||||
for proc in stack[::-1]:
|
for proc in stack[::-1]:
|
||||||
|
|
Loading…
Reference in a new issue