MCPcopy Create free account
hub / github.com/Bitmessage/PyBitmessage / _unpack_integer

Function _unpack_integer

src/fallback/umsgpack/umsgpack.py:593–614  ·  view source on GitHub ↗
(code, fp, options)

Source from the content-addressed store, hash-verified

591
592
593def _unpack_integer(code, fp, options):
594 if (ord(code) & 0xe0) == 0xe0:
595 return struct.unpack("b", code)[0]
596 elif code == b'\xd0':
597 return struct.unpack("b", _read_except(fp, 1))[0]
598 elif code == b'\xd1':
599 return struct.unpack(">h", _read_except(fp, 2))[0]
600 elif code == b'\xd2':
601 return struct.unpack(">i", _read_except(fp, 4))[0]
602 elif code == b'\xd3':
603 return struct.unpack(">q", _read_except(fp, 8))[0]
604 elif (ord(code) & 0x80) == 0x00:
605 return struct.unpack("B", code)[0]
606 elif code == b'\xcc':
607 return struct.unpack("B", _read_except(fp, 1))[0]
608 elif code == b'\xcd':
609 return struct.unpack(">H", _read_except(fp, 2))[0]
610 elif code == b'\xce':
611 return struct.unpack(">I", _read_except(fp, 4))[0]
612 elif code == b'\xcf':
613 return struct.unpack(">Q", _read_except(fp, 8))[0]
614 raise Exception("logic error, not int: 0x%02x" % ord(code))
615
616
617def _unpack_reserved(code, fp, options):

Callers

nothing calls this directly

Calls 1

_read_exceptFunction · 0.85

Tested by

no test coverage detected