#NEWLINE# def update( self , template ) : #NEWLINE# #INDENT# self . load_mapping ( ) #NEWLINE# self . load_parameters ( ) #NEWLINE# self . load_conditions ( ) #NEWLINE# old_template = self . _resource_json_map #NEWLINE# new_template = template [ 'Resources' ] #NEWLINE# self . _resource_json_map = new_template #NEWLINE# new_resource_names = ( set ( new_template ) - set ( old_template ) ) #NEWLINE# for resource_name in new_resource_names : #NEWLINE# #INDENT# resource_json = new_template [ resource_name ] #NEWLINE# new_resource = parse_and_create_resource ( resource_name , resource_json , self , self . _region_name ) #NEWLINE# self . _parsed_resources [ resource_name ] = new_resource #NEWLINE# #UNINDENT# removed_resource_nams = ( set ( old_template ) - set ( new_template ) ) #NEWLINE# for resource_name in removed_resource_nams : #NEWLINE# #INDENT# resource_json = old_template [ resource_name ] #NEWLINE# parse_and_delete_resource ( resource_name , resource_json , self , self . _region_name ) #NEWLINE# self . _parsed_resources . pop ( resource_name ) #NEWLINE# #UNINDENT# resources_to_update = set ( ( name for name in new_template if ( ( name in old_template ) and ( new_template [ name ] != old_template [ name ] ) ) ) ) #NEWLINE# tries = 1 #NEWLINE# while ( resources_to_update and ( tries < 5 ) ) : #NEWLINE# #INDENT# for resource_name in resources_to_update . copy ( ) : #NEWLINE# #INDENT# resource_json = new_template [ resource_name ] #NEWLINE# try : #NEWLINE# #INDENT# changed_resource = parse_and_update_resource ( resource_name , resource_json , self , self . _region_name ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# last_exception = e #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _parsed_resources [ resource_name ] = changed_resource #NEWLINE# resources_to_update . remove ( resource_name ) #NEWLINE# #UNINDENT# #UNINDENT# tries += 1 #NEWLINE# #UNINDENT# if ( tries == 5 ) : #NEWLINE# #INDENT# raise last_exception