def _validateChecksum(sentence):
 if (sentence[(-3):(-2)] == '*'):
  (reference, source) = (int(sentence[(-2):], 16), sentence[1:(-3)])
  computed = reduce(operator.xor, [ord(x) for x in iterbytes(source)])
  if (computed != reference):
   raise base.InvalidChecksum(('%02x != %02x' % (computed, reference)))

def _validateChecksum ( sentence ) : if ( sentence [ ( - 3 ) : ( - 2 ) ] == '*' ) : ( reference , source ) = ( int ( sentence [ ( - 2 ) : ] , 16 ) , sentence [ 1 : ( - 3 ) ] ) computed = reduce ( operator . xor , [ ord ( x ) for x in iterbytes ( source ) ] ) if ( computed != reference ) : raise base . InvalidChecksum ( ( '%02x != %02x' % ( computed , reference ) ) )
validates the checksum of an nmea sentence .