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

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

eric ide

mercurial