@@ -44,24 +44,23 @@ def __init__(self, format_size=None):
4444
4545 def deserialize (self , response ):
4646 self .timestamp = datetime .now ()
47- _msg_length = len (response )
4847 if response [:4 ] != MESSAGE_HEADER :
4948 raise InvalidMessageHeader (
5049 f"Invalid message header { str (response [:4 ])} for { self .__class__ .__name__ } "
5150 )
52- if response [_msg_length - 2 :] != MESSAGE_FOOTER :
51+ if response [- 2 :] != MESSAGE_FOOTER :
5352 raise InvalidMessageFooter (
54- f"Invalid message footer { str (response [_msg_length - 2 :])} for { self .__class__ .__name__ } "
53+ f"Invalid message footer { str (response [- 2 :])} for { self .__class__ .__name__ } "
5554 )
56- _calculated_checksum = self .calculate_checksum (response [4 : _msg_length - 6 ])
57- _message_checksum = response [_msg_length - 6 : _msg_length - 2 ]
55+ _calculated_checksum = self .calculate_checksum (response [4 : - 6 ])
56+ _message_checksum = response [- 6 : - 2 ]
5857 if _calculated_checksum != _message_checksum :
5958 raise InvalidMessageChecksum (
6059 f"Invalid checksum for { self .__class__ .__name__ } , expected { str (_calculated_checksum )} got { str (_message_checksum )} " ,
6160 )
62- if _msg_length != len (self ):
61+ if len ( response ) != len (self ):
6362 raise InvalidMessageLength (
64- f"Invalid message length received for { self .__class__ .__name__ } , expected { str (len (self ))} bytes got { str (_msg_length )} "
63+ f"Invalid message length received for { self .__class__ .__name__ } , expected { str (len (self ))} bytes got { str (len ( response ) )} "
6564 )
6665
6766 self .msg_id = response [4 :8 ]
0 commit comments