#NEWLINE# @ staticmethod #NEWLINE# def get_approval_votes( patch ) : #NEWLINE# #INDENT# levels = [ '-2' , '2' , '-1' , '1' ] #NEWLINE# votes = { #NEWLINE# #INDENT# 'c' : { #NEWLINE# #INDENT# 'total' : collections . defaultdict ( int ) , #NEWLINE# 'list' : [ ] , #NEWLINE# 'summary' : '' , #NEWLINE# 'details' : '' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'v' : { #NEWLINE# #INDENT# 'total' : collections . defaultdict ( int ) , #NEWLINE# 'list' : [ ] , #NEWLINE# 'summary' : '' , #NEWLINE# 'details' : '' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'w' : { #NEWLINE# #INDENT# 'total' : collections . defaultdict ( int ) , #NEWLINE# 'list' : [ ] , #NEWLINE# 'summary' : '' , #NEWLINE# 'details' : '' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# for approval in patch . approvals : #NEWLINE# #INDENT# got_type = approval . action [ 0 : 1 ] . lower ( ) #NEWLINE# if ( got_type not in votes ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# vote = str ( approval . value ) #NEWLINE# votes [ got_type ] [ 'total' ] [ vote ] = ( votes [ got_type ] [ 'total' ] [ vote ] + 1 ) #NEWLINE# votes [ got_type ] [ 'list' ] . append ( vote ) #NEWLINE# #UNINDENT# for key in votes . keys ( ) : #NEWLINE# #INDENT# votes [ key ] [ 'details' ] = ',' . join ( votes [ key ] [ 'list' ] ) #NEWLINE# vals = [ ] #NEWLINE# for level in levels : #NEWLINE# #INDENT# if ( level in votes [ key ] [ 'total' ] ) : #NEWLINE# #INDENT# votes [ key ] [ 'summary' ] = level #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return votes