Skip to content

Commit 7634acf

Browse files
committed
Comments corrections
1 parent 050648f commit 7634acf

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

pyjsonrpclite/jsonrpc.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class JsonRpcException(Exception):
1010
class JsonRpcParseError(Exception):
1111
"""Raised if Parse JSON-RPC 2.0 string failed.
1212
Params:
13-
rpcError - JsonRpcError """
13+
rpcError - `JsonRpcError` """
1414
def __init__(self, rpcError):
1515
Exception.__init__(self, rpcError)
1616
self.rpcError = rpcError
@@ -71,15 +71,15 @@ class JsonRpcErrorResponse(JsonRpcMessage):
7171
'''JSON-RPC 2.0 Response Object reporting request error.
7272
Params:
7373
id -- errornous request id or None,
74-
err - JsonRpcError object with an error data
74+
err - `JsonRpcError` object with an error data
7575
'''
7676
def __init__(self, id, err):
7777
self.id = id
7878
self.error = err
7979

8080

8181
class JsonRpcParsedType(object):
82-
'''Types used by parser to identify parsedType result in JsonRpcParsed'''
82+
'''Types used by parser to identify parsedType result in `JsonRpcParsed`'''
8383
INVALID = 'INVALID'
8484
REQUEST = 'REQUEST'
8585
NOTIFICATION = 'NOTIFICATION'
@@ -90,17 +90,17 @@ class JsonRpcParsedType(object):
9090
class JsonRpcParsed(object):
9191
'''Presents a json string parse result: parsedType and payload.
9292
Params:
93-
parsedType -- JsonRpcParsedType,
94-
payload -- JsonRpcMessage or JsonRpcError if parse failed'''
93+
parsedType -- <Enum|`JsonRpcParsedType`>,
94+
payload -- `JsonRpcMessage`'''
9595
def __init__(self, parsedType, payload):
9696
self.parsedType = parsedType
9797
self.payload = payload
9898

9999
@classmethod
100100
def Parse(cls, jsonstr):
101101
'''Parses json formatted string.
102-
Raises JsonRpcParseError if Parse fails.
103-
Return a JsonRpcParsed.'''
102+
Raises `JsonRpcParseError` if Parse fails.
103+
Return a `JsonRpcParsed`.'''
104104

105105
def SubHasId(jsondict):
106106
return 'id' in jsondict
@@ -124,7 +124,7 @@ def SubIsMethodCorrect(jsondict):
124124

125125
def SubValidateHeader(jsondict):
126126
'''Parses header and validate values.
127-
Raises JsonRpcException in case of error'''
127+
Raises `JsonRpcException` in case of error'''
128128
if not 'jsonrpc' in jsondict:
129129
raise JsonRpcException('Message have no "jsonrpc" field')
130130
if jsondict['jsonrpc'] <> '2.0':
@@ -138,7 +138,7 @@ def SubValidateMethod(jsondict):
138138
raise JsonRpcException('Invalid "method" field value')
139139

140140
def SubValidateParams(params):
141-
'''Checks if params not empty. Raises JsonRpcException if invalid.
141+
'''Checks if params not empty. Raises `JsonRpcException` if invalid.
142142
Params:
143143
params -- {scalar|array|object} value of jsondict['params']
144144
'''
@@ -169,7 +169,7 @@ def SubValidateErrorObj(errdict):
169169
def SubParseNotification(jsondict):
170170
'''Parses jsondict, validates JSON-RPC 2.0 Notification structure and values.
171171
Doesn't check JSON-RPC 2.0 "jsonrpc" and "id".
172-
Raises JsonRpcParseError if parse failed, or params invalid.'''
172+
Raises `JsonRpcParseError` if parse failed, or params invalid.'''
173173
try:
174174
SubValidateMethod(jsondict)
175175
except JsonRpcException as e:
@@ -185,7 +185,7 @@ def SubParseNotification(jsondict):
185185
def SubParseRequest(jsondict):
186186
'''Parses jsondict, validates JSON-RPC 2.0 Request structure and values.
187187
Doesn't check JSON-RPC 2.0 "jsonrpc","id", "method".
188-
Raises JsonRpcParseError if parse failed, or params invalid.'''
188+
Raises `JsonRpcParseError` if parse failed, or params invalid.'''
189189
id = jsondict['id']
190190
method = jsondict['method']
191191
params = jsondict.get('params', None)
@@ -199,7 +199,7 @@ def SubParseRequest(jsondict):
199199
def SubParseSuccessResponse(jsondict):
200200
'''Parses jsondict, validates JSON-RPC 2.0 Response Success structure and values.
201201
Doesn't check JSON-RPC 2.0 "jsonrpc","id".
202-
Raises JsonRpcParseError if parse failed, or result invalid.
202+
Raises `JsonRpcParseError` if parse failed, or result invalid.
203203
Params:
204204
jsondict - object, json parsed object
205205
'''
@@ -209,7 +209,7 @@ def SubParseSuccessResponse(jsondict):
209209
def SubParseErrorResponse(jsondict):
210210
'''Parses jsondict, validates JSON-RPC 2.0 Response Error structure and values.
211211
Doesn't check JSON-RPC 2.0 "jsonrpc","id".
212-
Raises JsonRpcParseError if parse failed, or error object invalid.
212+
Raises `JsonRpcParseError` if parse failed, or error object invalid.
213213
Params:
214214
jsondict - object, json parsed object
215215
'''
@@ -225,7 +225,7 @@ def SubParseErrorResponse(jsondict):
225225

226226
def SubParseJsonRpcObject(jsondict):
227227
'''Check if jsondict is valid JSON-RPC 2.0 object.
228-
Returns JsonRpcParsed object containing Parse results.'''
228+
Returns `JsonRpcParsed` object containing Parse results.'''
229229
try:
230230
SubValidateHeader(jsondict)
231231
except JsonRpcException as e:
@@ -259,8 +259,8 @@ def SubParseJsonRpcObject(jsondict):
259259
parsedObjInfo = SubParseJsonRpcObject(jsondict)
260260
except JsonRpcParseError as e:
261261
raise
262-
'''except Exception as e:
263-
raise JsonRpcParseError(JsonRpcError.InternalError(str(e)))'''
262+
except Exception as e:
263+
raise JsonRpcParseError(JsonRpcError.InternalError(str(e)))
264264
return parsedObjInfo
265265

266266
class JsonRpcError(object):
@@ -283,7 +283,7 @@ def Error(cls, code, message, data = None):
283283

284284
@classmethod
285285
def ParseError(cls, data = None):
286-
'''Creates JsonRpcError instance for prdefined JSON-RPC 2.0 error.
286+
'''Creates `JsonRpcError` instance for prdefined JSON-RPC 2.0 error.
287287
Code -32700. Invalid JSON was received by the server.
288288
An error occurred on the server while parsing the JSON text.
289289
'''
@@ -293,31 +293,31 @@ def ParseError(cls, data = None):
293293

294294
@classmethod
295295
def InvalidRequest(cls, data = None):
296-
'''Creates JsonRpcError instance for prdefined JSON-RPC 2.0 error.
296+
'''Creates `JsonRpcError` instance for prdefined JSON-RPC 2.0 error.
297297
Code -32600. The JSON sent is not a valid Request object.'''
298298
code = -32600
299299
message = 'Invalid Request'
300300
return JsonRpcError(code, message, data)
301301

302302
@classmethod
303303
def MethodNotFound(cls, data = None):
304-
'''Creates JsonRpcError instance for prdefined JSON-RPC 2.0 error.
304+
'''Creates `JsonRpcError` instance for prdefined JSON-RPC 2.0 error.
305305
Code -32601. The method does not exist / is not available.'''
306306
code = -32601
307307
message = 'Method Not Found'
308308
return JsonRpcError(code, message, data)
309309

310310
@classmethod
311311
def InvalidParams(cls, data = None):
312-
'''Creates JsonRpcError instance for prdefined JSON-RPC 2.0 error.
312+
'''Creates `JsonRpcError` instance for prdefined JSON-RPC 2.0 error.
313313
Code -32602. Invalid method parameter(s).'''
314314
code = -32602
315315
message = 'Invalid Params'
316316
return JsonRpcError(code, message, data)
317317

318318
@classmethod
319319
def InternalError(cls, data = None):
320-
'''Creates JsonRpcError instance for prdefined JSON-RPC 2.0 error.
320+
'''Creates `JsonRpcError` instance for prdefined JSON-RPC 2.0 error.
321321
Code -32603. Internal JSON-RPC error.'''
322322
code = -32603
323323
message = 'Internal Error'

0 commit comments

Comments
 (0)