Method: gzip._GzipReader._read_gzip_header
Calls: 341, Exceptions: 9, Paths: 6Back
Path 1: 244 calls (0.72)
True (244)
1def _read_gzip_header(self):
2 magic = self._fp.read(2)
3 if magic == b'':
4 return False
5
6 if magic != b'\037\213':
7 raise BadGzipFile('Not a gzipped file (%r)' % magic)
8
9 (method, flag,
10 self._last_mtime) = struct.unpack("<BBIxx", self._read_exact(8))
11 if method != 8:
12 raise BadGzipFile('Unknown compression method')
13
14 if flag & FEXTRA:
15 # Read & discard the extra field, if present
16 extra_len, = struct.unpack("<H", self._read_exact(2))
17 self._read_exact(extra_len)
18 if flag & FNAME:
19 # Read and discard a null-terminated string containing the filename
20 while True:
21 s = self._fp.read(1)
22 if not s or s==b'\000':
23 break
24 if flag & FCOMMENT:
25 # Read and discard a null-terminated string containing a comment
26 while True:
27 s = self._fp.read(1)
28 if not s or s==b'\000':
29 break
30 if flag & FHCRC:
31 self._read_exact(2) # Read & discard the 16-bit header CRC
32 return True
Path 2: 59 calls (0.17)
False (59)
1def _read_gzip_header(self):
2 magic = self._fp.read(2)
3 if magic == b'':
4 return False
5
6 if magic != b'\037\213':
7 raise BadGzipFile('Not a gzipped file (%r)' % magic)
8
9 (method, flag,
10 self._last_mtime) = struct.unpack("<BBIxx", self._read_exact(8))
11 if method != 8:
12 raise BadGzipFile('Unknown compression method')
13
14 if flag & FEXTRA:
15 # Read & discard the extra field, if present
16 extra_len, = struct.unpack("<H", self._read_exact(2))
17 self._read_exact(extra_len)
18 if flag & FNAME:
19 # Read and discard a null-terminated string containing the filename
20 while True:
21 s = self._fp.read(1)
22 if not s or s==b'\000':
23 break
24 if flag & FCOMMENT:
25 # Read and discard a null-terminated string containing a comment
26 while True:
27 s = self._fp.read(1)
28 if not s or s==b'\000':
29 break
30 if flag & FHCRC:
31 self._read_exact(2) # Read & discard the 16-bit header CRC
32 return True
Path 3: 28 calls (0.08)
True (28)
1def _read_gzip_header(self):
2 magic = self._fp.read(2)
3 if magic == b'':
4 return False
5
6 if magic != b'\037\213':
7 raise BadGzipFile('Not a gzipped file (%r)' % magic)
8
9 (method, flag,
10 self._last_mtime) = struct.unpack("<BBIxx", self._read_exact(8))
11 if method != 8:
12 raise BadGzipFile('Unknown compression method')
13
14 if flag & FEXTRA:
15 # Read & discard the extra field, if present
16 extra_len, = struct.unpack("<H", self._read_exact(2))
17 self._read_exact(extra_len)
18 if flag & FNAME:
19 # Read and discard a null-terminated string containing the filename
20 while True:
21 s = self._fp.read(1)
22 if not s or s==b'\000':
23 break
24 if flag & FCOMMENT:
25 # Read and discard a null-terminated string containing a comment
26 while True:
27 s = self._fp.read(1)
28 if not s or s==b'\000':
29 break
30 if flag & FHCRC:
31 self._read_exact(2) # Read & discard the 16-bit header CRC
32 return True
Path 4: 8 calls (0.02)
EOFError (8)
1def _read_gzip_header(self):
2 magic = self._fp.read(2)
3 if magic == b'':
4 return False
5
6 if magic != b'\037\213':
7 raise BadGzipFile('Not a gzipped file (%r)' % magic)
8
9 (method, flag,
10 self._last_mtime) = struct.unpack("<BBIxx", self._read_exact(8))
11 if method != 8:
12 raise BadGzipFile('Unknown compression method')
13
14 if flag & FEXTRA:
15 # Read & discard the extra field, if present
16 extra_len, = struct.unpack("<H", self._read_exact(2))
17 self._read_exact(extra_len)
18 if flag & FNAME:
19 # Read and discard a null-terminated string containing the filename
20 while True:
21 s = self._fp.read(1)
22 if not s or s==b'\000':
23 break
24 if flag & FCOMMENT:
25 # Read and discard a null-terminated string containing a comment
26 while True:
27 s = self._fp.read(1)
28 if not s or s==b'\000':
29 break
30 if flag & FHCRC:
31 self._read_exact(2) # Read & discard the 16-bit header CRC
32 return True
Path 5: 1 calls (0.0)
BadGzipFile (1)
1def _read_gzip_header(self):
2 magic = self._fp.read(2)
3 if magic == b'':
4 return False
5
6 if magic != b'\037\213':
7 raise BadGzipFile('Not a gzipped file (%r)' % magic)
8
9 (method, flag,
10 self._last_mtime) = struct.unpack("<BBIxx", self._read_exact(8))
11 if method != 8:
12 raise BadGzipFile('Unknown compression method')
13
14 if flag & FEXTRA:
15 # Read & discard the extra field, if present
16 extra_len, = struct.unpack("<H", self._read_exact(2))
17 self._read_exact(extra_len)
18 if flag & FNAME:
19 # Read and discard a null-terminated string containing the filename
20 while True:
21 s = self._fp.read(1)
22 if not s or s==b'\000':
23 break
24 if flag & FCOMMENT:
25 # Read and discard a null-terminated string containing a comment
26 while True:
27 s = self._fp.read(1)
28 if not s or s==b'\000':
29 break
30 if flag & FHCRC:
31 self._read_exact(2) # Read & discard the 16-bit header CRC
32 return True
Path 6: 1 calls (0.0)
True (1)
1def _read_gzip_header(self):
2 magic = self._fp.read(2)
3 if magic == b'':
4 return False
5
6 if magic != b'\037\213':
7 raise BadGzipFile('Not a gzipped file (%r)' % magic)
8
9 (method, flag,
10 self._last_mtime) = struct.unpack("<BBIxx", self._read_exact(8))
11 if method != 8:
12 raise BadGzipFile('Unknown compression method')
13
14 if flag & FEXTRA:
15 # Read & discard the extra field, if present
16 extra_len, = struct.unpack("<H", self._read_exact(2))
17 self._read_exact(extra_len)
18 if flag & FNAME:
19 # Read and discard a null-terminated string containing the filename
20 while True:
21 s = self._fp.read(1)
22 if not s or s==b'\000':
23 break
24 if flag & FCOMMENT:
25 # Read and discard a null-terminated string containing a comment
26 while True:
27 s = self._fp.read(1)
28 if not s or s==b'\000':
29 break
30 if flag & FHCRC:
31 self._read_exact(2) # Read & discard the 16-bit header CRC
32 return True