src/eric7/Plugins/CheckerPlugins/SyntaxChecker/jsonCheckSyntax.py

branch
eric7
changeset 10341
3fdffd9cc21d
parent 10111
049fbbd2253d
child 10439
21c28b0f9e41
equal deleted inserted replaced
10340:548b4c7f410e 10341:3fdffd9cc21d
15 def initService(): 15 def initService():
16 """ 16 """
17 Initialize the service and return the entry point. 17 Initialize the service and return the entry point.
18 18
19 @return the entry point for the background client 19 @return the entry point for the background client
20 @rtype func 20 @rtype function
21 """ 21 """
22 return jsonSyntaxCheck 22 return jsonSyntaxCheck
23 23
24 24
25 def initBatchService(): 25 def initBatchService():
26 """ 26 """
27 Initialize the batch service and return the entry point. 27 Initialize the batch service and return the entry point.
28 28
29 @return the entry point for the background client 29 @return the entry point for the background client
30 @rtype func 30 @rtype function
31 """ 31 """
32 return jsonSyntaxBatchCheck 32 return jsonSyntaxBatchCheck
33 33
34 34
35 def jsonSyntaxCheck(file, codestring): 35 def jsonSyntaxCheck(file, codestring):
38 38
39 @param file source filename 39 @param file source filename
40 @type str 40 @type str
41 @param codestring string containing the code to check 41 @param codestring string containing the code to check
42 @type str 42 @type str
43 @return dictionary with the keys 'error' and 'warnings' which 43 @return list of dictionaries with the key 'error' which contain a tuple with
44 hold a list containing details about the error/ warnings 44 details about the syntax error. Each tuple contains the file name, line
45 (file name, line number, column, codestring (only at syntax 45 number, column, code string and the error message.
46 errors), the message, a list with arguments for the message) 46 @rtype list of dict
47 @rtype dict
48 """ 47 """
49 return __jsonSyntaxCheck(file, codestring) 48 return __jsonSyntaxCheck(file, codestring)
50 49
51 50
52 def jsonSyntaxBatchCheck(argumentsList, send, fx, cancelled, maxProcesses=0): 51 def jsonSyntaxBatchCheck(argumentsList, send, fx, cancelled, maxProcesses=0):
53 """ 52 """
54 Module function to check syntax for a batch of files. 53 Module function to check syntax for a batch of files.
55 54
56 @param argumentsList list of arguments tuples as given for yamlSyntaxCheck 55 @param argumentsList list of arguments tuples as given for jsonSyntaxCheck
57 @type list 56 @type list
58 @param send reference to send function 57 @param send reference to send function
59 @type func 58 @type function
60 @param fx registered service name 59 @param fx registered service name
61 @type str 60 @type str
62 @param cancelled reference to function checking for a cancellation 61 @param cancelled reference to function checking for a cancellation
63 @type func 62 @type function
64 @param maxProcesses number of processes to be used 63 @param maxProcesses number of processes to be used
65 @type int 64 @type int
66 """ 65 """
67 if maxProcesses == 0: 66 if maxProcesses == 0:
68 # determine based on CPU count 67 # determine based on CPU count
150 149
151 @param file source filename 150 @param file source filename
152 @type str 151 @type str
153 @param codestring string containing the code to check 152 @param codestring string containing the code to check
154 @type str 153 @type str
155 @return dictionary with the keys 'error' and 'warnings' which 154 @return list of dictionaries with the key 'error' which contain a tuple with
156 hold a list containing details about the error/ warnings 155 details about the syntax error. Each tuple contains the file name, line
157 (file name, line number, column, codestring (only at syntax 156 number, column, code string and the error message.
158 errors), the message, a list with arguments for the message) 157 @rtype list of dict
159 @rtype dict
160 """ 158 """
161 if codestring: 159 if codestring:
162 try: 160 try:
163 json.loads(codestring) 161 json.loads(codestring)
164 except json.JSONDecodeError as exc: 162 except json.JSONDecodeError as exc:

eric ide

mercurial