#NEWLINE# def decode( self , payload ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . reason = ord ( payload [ 0 ] ) #NEWLINE# if ( self . reason == 1 ) : #NEWLINE# #INDENT# self . data = ord ( payload [ 1 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( payload . reason == 2 ) : #NEWLINE# #INDENT# self . data = struct . unpack ( '>L' , payload [ 1 : ] ) [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . reason == 3 ) : #NEWLINE# #INDENT# self . data = ord ( payload [ 1 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# log . warning ( 'unknown error reason value {0}' . format ( self . reason ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# except ( TypeError , struct . error ) : #NEWLINE# #INDENT# raise DecodeError ( 'non matching error reason and data' )