code: def loadhex(self, fobj):
          
          if getattr(fobj, "read", None) is None:
              fobj = open(fobj, "r")
              fclose = fobj.close
          else:
              fclose = None
  
          self._offset = 0
          line = 0
  
          try:
              decode = self._decode_record
              try:
                  for s in fobj:
                      line += 1
                      decode(s, line)
              except _EndOfFile:
                  pass
          finally:
              if fclose:
                  fclose()
docs: Load hex file into internal buffer. This is not necessary
          if object was initialized with source set. This will overwrite
          addresses if object was already initialized.
  
          @param  fobj        file name or file-like object