Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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