@ -69,6 +69,10 @@ class Block(Base, Become, Conditional, Taggable):
''' object comparison based on _uuid '''
''' object comparison based on _uuid '''
return self . _uuid == other . _uuid
return self . _uuid == other . _uuid
def __ne__ ( self , other ) :
''' object comparison based on _uuid '''
return self . _uuid != other . _uuid
def get_vars ( self ) :
def get_vars ( self ) :
'''
'''
Blocks do not store variables directly , however they may be a member
Blocks do not store variables directly , however they may be a member
@ -173,21 +177,16 @@ class Block(Base, Become, Conditional, Taggable):
new_task = task . copy ( exclude_parent = True )
new_task = task . copy ( exclude_parent = True )
if task . _parent :
if task . _parent :
new_task . _parent = task . _parent . copy ( exclude_tasks = True )
new_task . _parent = task . _parent . copy ( exclude_tasks = True )
# go up the parentage tree until we find an
if task . _parent == new_block :
# object without a parent and make this new
# If task._parent is the same as new_block, just replace it
# block their parent
new_task . _parent = new_block
cur_obj = new_task
else :
while cur_obj . _parent :
# task may not be a direct child of new_block, search for the correct place to insert new_block
if cur_obj . _parent :
cur_obj = new_task . _parent
prev_obj = cur_obj
while cur_obj . _parent and cur_obj . _parent != new_block :
cur_obj = cur_obj . _parent
cur_obj = cur_obj . _parent
# Ensure that we don't make the new_block the parent of itself
if cur_obj != new_block :
cur_obj . _parent = new_block
cur_obj . _parent = new_block
else :
# prev_obj._parent is cur_obj, to allow for mutability we need to use prev_obj
prev_obj . _parent = new_block
else :
else :
new_task . _parent = new_block
new_task . _parent = new_block
new_task_list . append ( new_task )
new_task_list . append ( new_task )
@ -203,7 +202,7 @@ class Block(Base, Become, Conditional, Taggable):
new_me . _parent = None
new_me . _parent = None
if self . _parent and not exclude_parent :
if self . _parent and not exclude_parent :
new_me . _parent = self . _parent . copy ( exclude_tasks = exclude_tasks )
new_me . _parent = self . _parent . copy ( exclude_tasks = True )
if not exclude_tasks :
if not exclude_tasks :
new_me . block = _dupe_task_list ( self . block or [ ] , new_me )
new_me . block = _dupe_task_list ( self . block or [ ] , new_me )