@ -48,29 +48,38 @@ def load_list_of_blocks(ds, play, parent_block=None, role=None, task_include=Non
block_list = [ ]
if ds :
for block_ds in ds :
b = Block . load (
block_ds ,
play = play ,
parent_block = parent_block ,
role = role ,
task_include = task_include ,
use_handlers = use_handlers ,
variable_manager = variable_manager ,
loader = loader ,
)
count = iter ( range ( len ( ds ) ) )
for i in count :
block_ds = ds [ i ]
# Implicit blocks are created by bare tasks listed in a play without
# an explicit block statement. If we have two implicit blocks in a row,
# squash them down to a single block to save processing time later.
if b . _implicit and len ( block_list ) > 0 and block_list [ - 1 ] . _implicit :
for t in b . block :
if isinstance ( t . _parent , ( TaskInclude , IncludeRole ) ) :
t . _parent . _parent = block_list [ - 1 ]
else :
t . _parent = block_list [ - 1 ]
block_list [ - 1 ] . block . extend ( b . block )
else :
block_list . append ( b )
implicit_blocks = [ ]
while block_ds is not None and not Block . is_block ( block_ds ) :
implicit_blocks . append ( block_ds )
i + = 1
# Advance the iterator, so we don't repeat
next ( count , None )
try :
block_ds = ds [ i ]
except IndexError :
block_ds = None
# Loop both implicit blocks and block_ds as block_ds is the next in the list
for b in ( implicit_blocks , block_ds ) :
if b :
block_list . append (
Block . load (
b ,
play = play ,
parent_block = parent_block ,
role = role ,
task_include = task_include ,
use_handlers = use_handlers ,
variable_manager = variable_manager ,
loader = loader ,
)
)
return block_list