parameters: (bytes, bytesize)
return_statement: return unpacked[0]
docstring: Utility function to convert a bytearray into an integer.
  
      It interprets the bytearray in the little endian format. For a big endian
      bytearray, just do ba.reverse() on the object before passing it in.
docstring_summary: Utility function to convert a bytearray into an integer.
docstring_tokens: Utility function to convert a bytearray into an integer .
function: def bytearray_to_int(bytes, bytesize):
      """Utility function to convert a bytearray into an integer.
  
      It interprets the bytearray in the little endian format. For a big endian
      bytearray, just do ba.reverse() on the object before passing it in.
      """
      import struct
  
      if bytesize == 1:
          return bytes[0]
  
      # Little endian followed by a format character.
      template = "<%c"
      if bytesize == 2:
          fmt = template % 'h'
      elif bytesize == 4:
          fmt = template % 'i'
      elif bytesize == 4:
          fmt = template % 'q'
      else:
          return None
  
      unpacked = struct.unpack(fmt, str(bytes))
      return unpacked[0]
function_tokens: def bytearray_to_int ( bytes , bytesize ) : import struct if bytesize == 1 : return bytes [ 0 ] # Little endian followed by a format character. template = "<%c" if bytesize == 2 : fmt = template % 'h' elif bytesize == 4 : fmt = template % 'i' elif bytesize == 4 : fmt = template % 'q' else : return None unpacked = struct . unpack ( fmt , str ( bytes ) ) return unpacked [ 0 ]