Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _parse_notification(self, req):
if not isinstance(req[1], six.string_types):
raise MSGPACKRPCInvalidRequestError()
request = MSGPACKRPCRequest()
request.one_way = True
request.method = req[1]
params = req[2]
# params should not be None according to the spec; if there are
# no params, an empty array must be used
if isinstance(params, list):
request.args = params
else:
raise MSGPACKRPCInvalidParamsError(request_id=req[1])
return request
def _parse_request(self, req):
if not isinstance(req[2], six.string_types):
raise MSGPACKRPCInvalidRequestError(request_id=req[1])
request = MSGPACKRPCRequest()
request.one_way = False
request.method = req[2]
request.unique_id = req[1]
params = req[3]
# params should not be None according to the spec; if there are
# no params, an empty array must be used
if isinstance(params, list):
request.args = params
else:
raise MSGPACKRPCInvalidParamsError(request_id=req[1])
return request
def request_factory(self) -> "MSGPACKRPCRequest":
"""Factory for request objects.
Allows derived classes to use requests derived from :py:class:`MSGPACKRPCRequest`.
:rtype: :py:class:`MSGPACKRPCRequest`
"""
return MSGPACKRPCRequest()