@@ -225,13 +225,10 @@ def write(self, data):
225
225
_IGzipReader = _GzipReader
226
226
227
227
228
- def _create_simple_gzip_header (compresslevel : int ,
229
- mtime : Optional [SupportsInt ] = None ) -> bytes :
230
- """
231
- Write a simple gzip header with no extra fields.
232
- :param compresslevel: Compresslevel used to determine the xfl bytes.
233
- :param mtime: The mtime (must support conversion to a 32-bit integer).
234
- :return: A bytes object representing the gzip header.
228
+ def compress (data , compresslevel : int = _COMPRESS_LEVEL_BEST , * ,
229
+ mtime : Optional [SupportsInt ] = None ) -> bytes :
230
+ """Compress data in one shot and return the compressed string.
231
+ Optional argument is the compression level, in range of 0-3.
235
232
"""
236
233
if mtime is None :
237
234
mtime = time .time ()
@@ -240,14 +237,7 @@ def _create_simple_gzip_header(compresslevel: int,
240
237
xfl = 4 if compresslevel == _COMPRESS_LEVEL_FAST else 0
241
238
# Pack ID1 and ID2 magic bytes, method (8=deflate), header flags (no extra
242
239
# fields added to header), mtime, xfl and os (255 for unknown OS).
243
- return struct .pack ("<BBBBLBB" , 0x1f , 0x8b , 8 , 0 , int (mtime ), xfl , 255 )
244
-
245
-
246
- def compress (data , compresslevel = _COMPRESS_LEVEL_BEST , * , mtime = None ):
247
- """Compress data in one shot and return the compressed string.
248
- Optional argument is the compression level, in range of 0-3.
249
- """
250
- header = _create_simple_gzip_header (compresslevel , mtime )
240
+ header = struct .pack ("<BBBBLBB" , 0x1f , 0x8b , 8 , 0 , int (mtime ), xfl , 255 )
251
241
# use igzip_lib to compress the data without a gzip header but with a
252
242
# gzip trailer.
253
243
compressed = igzip_lib .compress (data , compresslevel ,
0 commit comments