def _parse_binary(stream, ptr=0):
	i = ptr
	deserialized = {}
	
	while i < len(stream):
		c = stream[i]
		
		if c == BIN_END:
			return deserialized, i
		
		nodename, i = _readtonull(stream, i + 1)
		
		if c == BIN_NONE:
			deserialized[nodename], i = _parse_binary(stream, i + 1)
		elif c == BIN_STRING:
			deserialized[nodename], i = _readtonull(stream, i + 1)
		elif c == BIN_WIDESTRING:
			raise Exception('NYI')
		elif c == BIN_INT32 or c == BIN_COLOR or c == BIN_POINTER:
			if len(stream) - i < 4:
				raise Exception('Invalid KV')
			value, = struct.unpack_from('i', stream, i + 1)
			deserialized[nodename], i = value, i + 4
		elif c == BIN_UINT64:
			if 8 < len(stream) - i:
				raise Exception('Invalid KV')
			value, = struct.unpack_from('q', stream, i + 1)
			deserialized[nodename], i = value, i + 8
		elif c == BIN_FLOAT32:
			if len(stream) - i < 4:
				raise Exception('Invalid KV')
			value, = struct.unpack_from('f', stream, i + 1)
			deserialized[nodename], i = 0, i + 4
		else:
			raise Exception('Unknown KV type')
			
		i += 1

	return deserialized, i
dataset/ETHPy150Open adamb70/CSGO-Market-Float-Finder/pysteamkit/vdf.py/_parse_binary/swapped operands of `<`