Quickly see if a file is a ZIP file by checking the magic number. The filename argument may be a file or file-like object too.
(filename)
| 224 | return False |
| 225 | |
| 226 | def is_zipfile(filename): |
| 227 | """Quickly see if a file is a ZIP file by checking the magic number. |
| 228 | |
| 229 | The filename argument may be a file or file-like object too. |
| 230 | """ |
| 231 | result = False |
| 232 | try: |
| 233 | if hasattr(filename, "read"): |
| 234 | result = _check_zipfile(fp=filename) |
| 235 | else: |
| 236 | with open(filename, "rb") as fp: |
| 237 | result = _check_zipfile(fp) |
| 238 | except OSError: |
| 239 | pass |
| 240 | return result |
| 241 | |
| 242 | def _EndRecData64(fpin, offset, endrec): |
| 243 | """ |
nothing calls this directly
no test coverage detected