@ -37,12 +37,13 @@ class Block(Base, Become, Conditional, Taggable):
# similar to the 'else' clause for exceptions
# similar to the 'else' clause for exceptions
#_otherwise = FieldAttribute(isa='list')
#_otherwise = FieldAttribute(isa='list')
def __init__ ( self , play = None , parent_block = None , role = None , task_include = None , use_handlers = False ):
def __init__ ( self , play = None , parent_block = None , role = None , task_include = None , use_handlers = False , implicit = False ):
self . _play = play
self . _play = play
self . _role = role
self . _role = role
self . _task_include = task_include
self . _task_include = task_include
self . _parent_block = parent_block
self . _parent_block = parent_block
self . _use_handlers = use_handlers
self . _use_handlers = use_handlers
self . _implicit = implicit
self . _dep_chain = [ ]
self . _dep_chain = [ ]
super ( Block , self ) . __init__ ( )
super ( Block , self ) . __init__ ( )
@ -66,22 +67,27 @@ class Block(Base, Become, Conditional, Taggable):
@staticmethod
@staticmethod
def load ( data , play = None , parent_block = None , role = None , task_include = None , use_handlers = False , variable_manager = None , loader = None ) :
def load ( data , play = None , parent_block = None , role = None , task_include = None , use_handlers = False , variable_manager = None , loader = None ) :
b = Block ( play = play , parent_block = parent_block , role = role , task_include = task_include , use_handlers = use_handlers )
implicit = not Block . is_block ( data )
b = Block ( play = play , parent_block = parent_block , role = role , task_include = task_include , use_handlers = use_handlers , implicit = implicit )
return b . load_data ( data , variable_manager = variable_manager , loader = loader )
return b . load_data ( data , variable_manager = variable_manager , loader = loader )
def preprocess_data ( self , ds ) :
@staticmethod
'''
def is_block ( ds ) :
If a simple task is given , an implicit block for that single task
is created , which goes in the main portion of the block
'''
is_block = False
is_block = False
if isinstance ( ds , dict ) :
for attr in ( ' block ' , ' rescue ' , ' always ' ) :
for attr in ( ' block ' , ' rescue ' , ' always ' ) :
if attr in ds :
if attr in ds :
is_block = True
is_block = True
break
break
return is_block
def preprocess_data ( self , ds ) :
'''
If a simple task is given , an implicit block for that single task
is created , which goes in the main portion of the block
'''
if not is_block :
if not Block. is_block( ds ) :
if isinstance ( ds , list ) :
if isinstance ( ds , list ) :
return super ( Block , self ) . preprocess_data ( dict ( block = ds ) )
return super ( Block , self ) . preprocess_data ( dict ( block = ds ) )
else :
else :