--- a/src/eric7/Plugins/CheckerPlugins/SyntaxChecker/jsonCheckSyntax.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Plugins/CheckerPlugins/SyntaxChecker/jsonCheckSyntax.py Wed Jul 13 14:55:47 2022 +0200 @@ -14,7 +14,7 @@ def initService(): """ Initialize the service and return the entry point. - + @return the entry point for the background client @rtype func """ @@ -24,7 +24,7 @@ def initBatchService(): """ Initialize the batch service and return the entry point. - + @return the entry point for the background client @rtype func """ @@ -34,7 +34,7 @@ def normalizeCode(codestring): """ Function to normalize the given code. - + @param codestring code to be normalized @type str @return normalized code @@ -42,16 +42,16 @@ """ codestring = codestring.replace("\r\n", "\n").replace("\r", "\n") - if codestring and codestring[-1] != '\n': - codestring += '\n' - + if codestring and codestring[-1] != "\n": + codestring += "\n" + return codestring def jsonSyntaxCheck(file, codestring): """ Function to check a JSON source file for syntax errors. - + @param file source filename @type str @param codestring string containing the code to check @@ -68,7 +68,7 @@ def jsonSyntaxBatchCheck(argumentsList, send, fx, cancelled, maxProcesses=0): """ Module function to check syntax for a batch of files. - + @param argumentsList list of arguments tuples as given for yamlSyntaxCheck @type list @param send reference to send function @@ -102,9 +102,8 @@ # Start worker processes workers = [ - multiprocessing.Process( - target=workerTask, args=(taskQueue, doneQueue) - ) for _ in range(NumberOfProcesses) + multiprocessing.Process(target=workerTask, args=(taskQueue, doneQueue)) + for _ in range(NumberOfProcesses) ] for worker in workers: worker.start() @@ -114,7 +113,7 @@ for i in range(len(argumentsList)): resultSent = False wasCancelled = False - + while not resultSent: try: # get result (waiting max. 3 seconds and send it to frontend @@ -126,18 +125,18 @@ if cancelled(): wasCancelled = True break - + if wasCancelled or cancelled(): # just exit the loop ignoring the results of queued tasks break - + if i < endIndex: taskQueue.put(argumentsList[i + initialTasks]) # Tell child processes to stop for _ in range(NumberOfProcesses): - taskQueue.put('STOP') - + taskQueue.put("STOP") + for worker in workers: worker.join() worker.close() @@ -146,13 +145,13 @@ def workerTask(inputQueue, outputQueue): """ Module function acting as the parallel worker for the syntax check. - + @param inputQueue input queue @type multiprocessing.Queue @param outputQueue output queue @type multiprocessing.Queue """ - for filename, args in iter(inputQueue.get, 'STOP'): + for filename, args in iter(inputQueue.get, "STOP"): source = args[0] result = __jsonSyntaxCheck(filename, source) outputQueue.put((filename, result)) @@ -161,7 +160,7 @@ def __jsonSyntaxCheck(file, codestring): """ Function to check a YAML source file for syntax errors. - + @param file source filename @type str @param codestring string containing the code to check @@ -173,19 +172,19 @@ @rtype dict """ import json - + codestring = normalizeCode(codestring) - + try: json.loads(codestring) except json.JSONDecodeError as exc: line = exc.lineno column = exc.colno error = exc.msg - + cline = min(len(codestring.splitlines()), int(line)) - 1 code = codestring.splitlines()[cline] - - return [{'error': (file, line, column, code, error)}] - + + return [{"error": (file, line, column, code, error)}] + return [{}]