Confusion_buddy
Confusion_buddy

Reputation: 348

Pylint not working as expected

Am using a pylint for checking error. My python codes in a directory and that directory contain many other sub folders and files. am checking recursively all folder file ends with .py. It is working fine.

My issue is when ever i run the script in main directory, only first python file get report proper. second and forth not working at all. pylint saying

    ************* Module test.py
    F:  1: No module named test.py
    ***************
Global evaluation
-----------------
Your code has been rated at 0.00/10 (previous run: 0.00/10)

Whenever i run my script in main directory only first file report is proper. pylint is not checking for none of other files. ( i have almost 50 python files in sub directories) .

Following is my code :- [ver : -Python 2.7.2+ ]

"""
Automated error handling using pylint
1. pylint --generate-rcfile > pylintrc

"""

import sys
import os 

if __name__ == '__main__' :
    if len(sys.argv) > 1:
        os.system(">output.txt")
        for r, d, f in os.walk(sys.argv[1]):
            for files in f:
                if files.endswith(".py"):
                    os.system("pylint %s >> output.txt" % files)
    else:
        os.system(">output.txt")
        for r, d, f in os.walk('.'):
            for files in f:
                if files.endswith(".py"):
                    os.system("pylint %s >> output.txt" % files)

how to get all (almost 50 files) file report correctly, with out existing after first file report. is this is the right way to do this? . Thanks in advance.

Upvotes: 1

Views: 2043

Answers (1)

gurney alex
gurney alex

Reputation: 13645

You need to pass the full path to pylint on the command line, i.e.

for filename in f:
    if filename.endswith(".py"):                       
        os.system("pylint %s >> output.txt" % os.path.join(r, filename))

And you won't get a very good pylint score on this script unless you use meaningful variable names :-)

Upvotes: 1

Related Questions