Skip to content

Commit 61f7459

Browse files
committed
Remove redundant code
1 parent 9abe43e commit 61f7459

File tree

1 file changed

+0
-51
lines changed

1 file changed

+0
-51
lines changed

src/zlib_ng/gzip_ng.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -180,57 +180,6 @@ def write(self, data):
180180
_GzipNGReader = _GzipReader
181181

182182

183-
def _read_exact(fp, n):
184-
'''Read exactly *n* bytes from `fp`
185-
This method is required because fp may be unbuffered,
186-
i.e. return short reads.
187-
'''
188-
data = fp.read(n)
189-
while len(data) < n:
190-
b = fp.read(n - len(data))
191-
if not b:
192-
raise EOFError("Compressed file ended before the "
193-
"end-of-stream marker was reached")
194-
data += b
195-
return data
196-
197-
198-
def _read_gzip_header(fp):
199-
'''Read a gzip header from `fp` and progress to the end of the header.
200-
Returns last mtime if header was present or None otherwise.
201-
'''
202-
magic = fp.read(2)
203-
if magic == b'':
204-
return None
205-
206-
if magic != b'\037\213':
207-
raise BadGzipFile('Not a gzipped file (%r)' % magic)
208-
209-
(method, flag, last_mtime) = struct.unpack("<BBIxx", _read_exact(fp, 8))
210-
if method != 8:
211-
raise BadGzipFile('Unknown compression method')
212-
213-
if flag & FEXTRA:
214-
# Read & discard the extra field, if present
215-
extra_len, = struct.unpack("<H", _read_exact(fp, 2))
216-
_read_exact(fp, extra_len)
217-
if flag & FNAME:
218-
# Read and discard a null-terminated string containing the filename
219-
while True:
220-
s = fp.read(1)
221-
if not s or s == b'\000':
222-
break
223-
if flag & FCOMMENT:
224-
# Read and discard a null-terminated string containing a comment
225-
while True:
226-
s = fp.read(1)
227-
if not s or s == b'\000':
228-
break
229-
if flag & FHCRC:
230-
_read_exact(fp, 2) # Read & discard the 16-bit header CRC
231-
return last_mtime
232-
233-
234183
def _create_simple_gzip_header(compresslevel: int,
235184
mtime=None) -> bytes:
236185
"""

0 commit comments

Comments
 (0)