code: def __init__(self, file):
      # type: (IO[bytes]) -> None
      def unpack(fmt):
          # type: (str) -> int
          try:
              (result,) = struct.unpack(
                  fmt, file.read(struct.calcsize(fmt))
              )  # type: (int, )
          except struct.error:
              raise _ELFFileHeader._InvalidELFFileHeader()
          return result
  
      self.e_ident_magic = unpack(">I")
      if self.e_ident_magic != self.ELF_MAGIC_NUMBER:
          raise _ELFFileHeader._InvalidELFFileHeader()
      self.e_ident_class = unpack("B")
      if self.e_ident_class not in {self.ELFCLASS32, self.ELFCLASS64}:
          raise _ELFFileHeader._InvalidELFFileHeader()
      self.e_ident_data = unpack("B")
      if self.e_ident_data not in {self.ELFDATA2LSB, self.ELFDATA2MSB}:
          raise _ELFFileHeader._InvalidELFFileHeader()
      self.e_ident_version = unpack("B")
      self.e_ident_osabi = unpack("B")
      self.e_ident_abiversion = unpack("B")
      self.e_ident_pad = file.read(7)
      format_h = "<H" if self.e_ident_data == self.ELFDATA2LSB else ">H"
      format_i = "<I" if self.e_ident_data == self.ELFDATA2LSB else ">I"
      format_q = "<Q" if self.e_ident_data == self.ELFDATA2LSB else ">Q"
      format_p = (
          format_i
          if self.e_ident_class == self.ELFCLASS32
          else format_q
      )
      self.e_type = unpack(format_h)
      self.e_machine = unpack(format_h)
      self.e_version = unpack(format_i)
      self.e_entry = unpack(format_p)
      self.e_phoff = unpack(format_p)
      self.e_shoff = unpack(format_p)
      self.e_flags = unpack(format_i)
      self.e_ehsize = unpack(format_h)
      self.e_phentsize = unpack(format_h)
      self.e_phnum = unpack(format_h)
      self.e_shentsize = unpack(format_h)
      self.e_shnum = unpack(format_h)
      self.e_shstrndx = unpack(format_h)
  
imports: from __future__ import absolute_import
  import distutils.util
  import collections
  import logging
  import os
  import platform
  import re
  import struct
  import sys
  import sysconfig
  import warnings
  from ._typing import TYPE_CHECKING, cast
label_desc: Use image node_id 1 to create a new _ELFFileHeader object from inherited base classes: object with example: obj = _ELFFileHeader(file)