Read and unpack the next bytes from a binary file. :param fid: :param num_bytes: Sum of combination of {2, 4, 8}, e.g. 2, 6, 16, 30, etc. :param format_char_sequence: List of {c, e, f, d, h, H, i, I, l, L, q, Q}. :param endian_character: Any of {@, =, <, >, !} :return: Tuple of r
(fid, num_bytes, format_char_sequence, endian_character="<")
| 74 | |
| 75 | |
| 76 | def read_next_bytes(fid, num_bytes, format_char_sequence, endian_character="<"): |
| 77 | """Read and unpack the next bytes from a binary file. |
| 78 | :param fid: |
| 79 | :param num_bytes: Sum of combination of {2, 4, 8}, e.g. 2, 6, 16, 30, etc. |
| 80 | :param format_char_sequence: List of {c, e, f, d, h, H, i, I, l, L, q, Q}. |
| 81 | :param endian_character: Any of {@, =, <, >, !} |
| 82 | :return: Tuple of read and unpacked values. |
| 83 | """ |
| 84 | data = fid.read(num_bytes) |
| 85 | return struct.unpack(endian_character + format_char_sequence, data) |
| 86 | |
| 87 | |
| 88 | def write_next_bytes(fid, data, format_char_sequence, endian_character="<"): |
no outgoing calls
no test coverage detected