def _detect_compressor(fileobj):
 fileobj.seek(0)
 first_bytes = fileobj.read(_MAX_PREFIX_LEN)
 fileobj.seek(0)
 if first_bytes.startswith(_ZLIB_PREFIX):
  return 'zlib'
 elif first_bytes.startswith(_GZIP_PREFIX):
  return 'gzip'
 elif first_bytes.startswith(_BZ2_PREFIX):
  return 'bz2'
 elif first_bytes.startswith(_LZMA_PREFIX):
  return 'lzma'
 elif first_bytes.startswith(_XZ_PREFIX):
  return 'xz'
 elif first_bytes.startswith(_ZFILE_PREFIX):
  return 'compat'
 return 'not-compressed'

def _detect_compressor ( fileobj ) : fileobj . seek ( 0 ) first_bytes = fileobj . read ( _MAX_PREFIX_LEN ) fileobj . seek ( 0 ) if first_bytes . startswith ( _ZLIB_PREFIX ) : return 'zlib' elif first_bytes . startswith ( _GZIP_PREFIX ) : return 'gzip' elif first_bytes . startswith ( _BZ2_PREFIX ) : return 'bz2' elif first_bytes . startswith ( _LZMA_PREFIX ) : return 'lzma' elif first_bytes . startswith ( _XZ_PREFIX ) : return 'xz' elif first_bytes . startswith ( _ZFILE_PREFIX ) : return 'compat' return 'not-compressed'
return the compressor matching fileobj .