Read the magic string to get the version of the file format. Parameters ---------- fp : filelike object Returns ------- major : int minor : int
(fp)
| 221 | return MAGIC_PREFIX + bytes([major, minor]) |
| 222 | |
| 223 | def read_magic(fp): |
| 224 | """ Read the magic string to get the version of the file format. |
| 225 | |
| 226 | Parameters |
| 227 | ---------- |
| 228 | fp : filelike object |
| 229 | |
| 230 | Returns |
| 231 | ------- |
| 232 | major : int |
| 233 | minor : int |
| 234 | """ |
| 235 | magic_str = _read_bytes(fp, MAGIC_LEN, "magic string") |
| 236 | if magic_str[:-2] != MAGIC_PREFIX: |
| 237 | msg = "the magic string is not correct; expected %r, got %r" |
| 238 | raise ValueError(msg % (MAGIC_PREFIX, magic_str[:-2])) |
| 239 | major, minor = magic_str[-2:] |
| 240 | return major, minor |
| 241 | |
| 242 | |
| 243 | def dtype_to_descr(dtype): |
no test coverage detected