def _compression_wrapper(file_obj, filename, mode):
    """
    This function will wrap the file_obj with an appropriate
    [de]compression mechanism based on the extension of the filename.

    file_obj must either be a filehandle object, or a class which behaves
        like one.

    If the filename extension isn't recognized, will simply return the original
    file_obj.
    """
    _, ext = os.path.splitext(filename)

    if _need_to_buffer(file_obj, mode, ext):
        warnings.warn('streaming gzip support unavailable, see %s' % _ISSUE_189_URL)
        file_obj = io.BytesIO(file_obj.read())
    if ext in _COMPRESSOR_REGISTRY and mode.endswith('+'):
        raise ValueError('transparent (de)compression unsupported for mode %r' % mode)

    try:
        callback = _COMPRESSOR_REGISTRY[ext]
    except KeyError:
        return file_obj
    else:
        return callback(file_obj, mode)
def _compression_wrapper ( file_obj , filename , mode ) : _ , ext = os . path . splitext ( filename ) if _need_to_buffer ( file_obj , mode , ext ) : warnings . warn ( 'streaming gzip support unavailable, see %s' % _ISSUE_189_URL ) file_obj = io . BytesIO ( file_obj . read ( ) ) if ext in _COMPRESSOR_REGISTRY and mode . endswith ( '+' ) : raise ValueError ( 'transparent (de)compression unsupported for mode %r' % mode ) try : callback = _COMPRESSOR_REGISTRY [ ext ] except KeyError : return file_obj else : return callback ( file_obj , mode )
This function will wrap the file_obj with an appropriate
    [de]compression mechanism based on the extension of the filename.

    file_obj must either be a filehandle object, or a class which behaves
        like one.

    If the filename extension isn't recognized, will simply return the original
    file_obj.