(f, bytelen: int = 1)
| 429 | |
| 430 | |
| 431 | def read_uint(f, bytelen: int = 1) -> int: |
| 432 | if bytelen == 1: |
| 433 | fmt = "B" |
| 434 | elif bytelen == 2: |
| 435 | fmt = "H" |
| 436 | elif bytelen == 4: |
| 437 | fmt = "I" |
| 438 | elif bytelen == 8: |
| 439 | fmt = "Q" |
| 440 | else: |
| 441 | raise Exception("Bytelen {0} is not supported".format(bytelen)) |
| 442 | res = struct.unpack(fmt, f.read(bytelen)) |
| 443 | return res[0] |
| 444 | |
| 445 | |
| 446 | def read_varuint(f) -> int: |
no test coverage detected