def str2long(data, endian):
 assert (1 <= len(data) <= 32)
 try:
  return unpack(_struct_format[endian][len(data)], data)[0]
 except KeyError:
  pass
 assert (endian in (BIG_ENDIAN, LITTLE_ENDIAN, MIDDLE_ENDIAN))
 shift = 0
 value = 0
 if (endian is BIG_ENDIAN):
  data = reversed(data)
 elif (endian is MIDDLE_ENDIAN):
  data = reversed(strswapmid(data))
 for character in data:
  byte = ord(character)
  value += (byte << shift)
  shift += 8
 return value

def str2long ( data , endian ) : assert ( 1 <= len ( data ) <= 32 ) try : return unpack ( _struct_format [ endian ] [ len ( data ) ] , data ) [ 0 ] except KeyError : pass assert ( endian in ( BIG_ENDIAN , LITTLE_ENDIAN , MIDDLE_ENDIAN ) ) shift = 0 value = 0 if ( endian is BIG_ENDIAN ) : data = reversed ( data ) elif ( endian is MIDDLE_ENDIAN ) : data = reversed ( strswapmid ( data ) ) for character in data : byte = ord ( character ) value += ( byte << shift ) shift += 8 return value
convert a raw data into a long integer .