docs: def hexdump(bytestr, width=75, height=24, snipat=-2, modulo=2, ellipsis=None):
      """Return hexdump representation of byte string.
  
      >>> hexdump(binascii.unhexlify('49492a00080000000e00fe0004000100'))
      '49 49 2a 00 08 00 00 00 0e 00 fe 00 04 00 01 00 II*.............'
  
      """
      size = len(bytestr)
      if size < 1 or width < 2 or height < 1:
          return ''
      if height == 1:
          addr = b''
          bytesperline = min(modulo * (((width - len(addr)) // 4) // modulo),
                             size)
          if bytesperline < 1:
              return ''
          nlines = 1
      else:
          addr = b'%%0%ix: ' % len(b'%x' % size)
          bytesperline = min(modulo * (((width - len(addr % 1)) // 4) // modulo),
                             size)
          if bytesperline < 1:
              return ''
          width = 3*bytesperline + len(addr % 1)
          nlines = (size - 1) // bytesperline + 1
  
      if snipat is None or snipat == 1:
          snipat = height
      elif 0 < abs(snipat) < 1:
          snipat = int(math.floor(height * snipat))
      if snipat < 0:
          snipat += height
  
      if height == 1 or nlines == 1:
          blocks = [(0, bytestr[:bytesperline])]
          addr = b''
          height = 1
          width = 3 * bytesperline
      elif height is None or nlines <= height:
          blocks = [(0, bytestr)]
      elif snipat <= 0:
          start = bytesperline * (nlines - height)
          blocks = [(start, bytestr[start:])]  # (start, None)
      elif snipat >= height or height < 3:
          end = bytesperline * height
          blocks = [(0, bytestr[:end])]  # (end, None)
      else:
          end1 = bytesperline * snipat
          end2 = bytesperline * (height - snipat - 1)
          blocks = [(0, bytestr[:end1]),
                    (size-end1-end2, None),
                    (size-end2, bytestr[size-end2:])]
  
      ellipsis = b'...' if ellipsis is None else str2bytes(ellipsis)
      result = []
      for start, bytestr in blocks:
          if bytestr is None:
              result.append(ellipsis)  # 'skip %i bytes' % start)
              continue
          hexstr = binascii.hexlify(bytestr)
          strstr = re.sub(br'[^\x20-\x7f]', b'.', bytestr)
          for i in range(0, len(bytestr), bytesperline):
              h = hexstr[2*i:2*i+bytesperline*2]
              r = (addr % (i + start)) if height > 1 else addr
              r += b' '.join(h[i:i+2] for i in range(0, 2*bytesperline, 2))
              r += b' ' * (width - len(r))
              r += strstr[i:i+bytesperline]
              result.append(r)
      result = b'\n'.join(result)
      if sys.version_info[0] == 3:
          result = result.decode('ascii')
      return result