How to get a brief summary or exactly the number of errors and warnings using pylint in python -
how brief summary of pylint error messages or number of pylint errors, warnings, refactors using python code?
pylint -rn
this allows pylint output messages , excludes reports. have tried till :
lint_arg = "pylint -rn %s"%file_name pr = subprocess.popen( arg, cwd=os.path.dirname(lint_path), shell=true, stdout=subprocess.pipe, stderr=subprocess.pipe) (out, error) = pr.communicate() pylint_result = out + "\n" + error file=open("pylint_output",w) file.write(pylint_result) file.close()
i number of lines in errors, warnings occurred , move info string. thought below:
step 1 : run pylint in python script using subprocess.popen() step 2 : store output in file or variable . step 3: parse file , generate expected output below:
expected output : next file < filename> has : 5 warnings in line number : 11, 34 ,56 (lines in warnings occurred) 2 errors in line number :2 (lines in errors occurred).
how can help of pylint command s or utilize of python script? help appreciated. advance thanks.
first, don't utilize popen
, quote pylint's docs:
to silently run pylint on module_name.py module, , standart output , error:
from pylint import epylint lint (pylint_stdout, pylint_stderr) = lint.py_run('module_name.py', true)
second, see output format, man pylint
says:
using default text output, message format is:
message_type: line_num:[object:] message
assuming line
line of pylint output, should gather need:
pylint_res = {'c': [], 'r': [], 'w': [], 'e': [], 'f': []} msg_type, lineno = line.split(':', 2)[:2] pylint_res[msg_type].append(lineno)
all need iterate on pylint's output, adding above pylint_res
, , printing out results.
python python-2.7 pylint
No comments:
Post a Comment