1-based indexing for RPC list parameters

This commit is contained in:
Jiang Yio 2022-10-01 00:24:38 -04:00
parent b3195bcd82
commit 26b4a116ba

2
rpc.py
View File

@ -32,7 +32,7 @@ def l_pack(value: Any, envelope: int=3, wrapped: bool=True, basictype=b'0', enco
bare = b't'.join(l_pack(k, envelope=envelope, wrapped=False, encoding=encoding) + l_pack(v, envelope=envelope, wrapped=False, encoding=encoding) for k, v in value.items())
return (b'2' + bare + b'f') if wrapped else bare
elif not isinstance(value, str) and hasattr(value, '__iter__'):
bare = b't'.join(l_pack(k, envelope=envelope, wrapped=False, encoding=encoding) + l_pack(v, envelope=envelope, wrapped=False, encoding=encoding) for k, v in enumerate(value))
bare = b't'.join(l_pack(k, envelope=envelope, wrapped=False, encoding=encoding) + l_pack(v, envelope=envelope, wrapped=False, encoding=encoding) for k, v in enumerate(value, start=1))
return (b'2' + bare + b'f') if wrapped else bare
elif isinstance(value, MReference):
return l_pack(str(value), envelope=envelope, basictype=b'1', encoding=encoding)