How to use the ratarmount.SQLiteIndexedTar._detectCompression function in ratarmount

To help you get started, we’ve selected a few ratarmount examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mxmlnkn / ratarmount / ratarmount.py View on Github external
def _openCompressedFile( fileobj, gzipSeekPointSpacing ):
        """Opens a file possibly undoing the compression."""
        rawFile = None
        tarFile = fileobj
        compression = SQLiteIndexedTar._detectCompression( fileobj = tarFile )

        if compression == 'bz2':
            rawFile = tarFile # save so that garbage collector won't close it!
            tarFile = IndexedBzip2File( rawFile.fileno() )
        elif compression == 'gz':
            rawFile = tarFile # save so that garbage collector won't close it!
            # drop_handles keeps a file handle opening as is required to call tell() during decoding
            tarFile = IndexedGzipFile( fileobj = rawFile,
                                       drop_handles = False,
                                       spacing = gzipSeekPointSpacing )

        return tarFile, rawFile, compression