#NEWLINE# def get_value( self , appeared_only , in_repeat ) : #NEWLINE# #INDENT# result = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for each in self : #NEWLINE# #INDENT# this_result = each . get_value ( appeared_only , ( in_repeat or self . repeat ) ) #NEWLINE# repeated_keys = set ( result ) . intersection ( this_result ) #NEWLINE# for key in repeated_keys : #NEWLINE# #INDENT# old_value = result [ key ] #NEWLINE# new_value = this_result [ key ] #NEWLINE# logger . debug ( '%s - old: %s, new: %s' , key , old_value , new_value ) #NEWLINE# if ( key . startswith ( '-' ) and any ( ( isinstance ( x , ( int , NoneType ) ) for x in ( old_value , new_value ) ) ) ) : #NEWLINE# #INDENT# if ( appeared_only and ( old_value == new_value == ( - 1 ) ) ) : #NEWLINE# #INDENT# final_value = ( - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if set ( ( old_value , new_value ) ) . issubset ( ( None , ( - 1 ) ) ) : #NEWLINE# #INDENT# final_value = [ ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# final_value = ( ( old_value or 0 ) + ( new_value or 0 ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if all ( ( isinstance ( x , int ) for x in ( old_value , new_value ) ) ) : #NEWLINE# #INDENT# final_value = ( old_value + new_value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# final_value = [ ] #NEWLINE# for each_value in ( old_value , new_value ) : #NEWLINE# #INDENT# if ( each_value is None ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( each_value , list ) : #NEWLINE# #INDENT# final_value . extend ( each_value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# final_value . append ( each_value ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# logger . debug ( 'merge %s value as %s' , key , final_value ) #NEWLINE# this_result [ key ] = final_value #NEWLINE# #UNINDENT# result . update ( this_result ) #NEWLINE# #UNINDENT# logger . debug ( '%s return value %s' , self , result ) #NEWLINE# return result