-
-
Save jacohend/0f5006093d543dd6e625 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
''' | |
Author: gregorynicholas (github), modified by Jacob Henderson (jacohend, github) | |
Module that runs pylint on all python scripts found in a directory tree.. | |
''' | |
import os | |
import re | |
import sys | |
passed = 0 | |
failed = 0 | |
def check(module): | |
global passed, failed | |
''' | |
apply pylint to the file specified if it is a *.py file | |
''' | |
if module[-3:] == ".py": | |
print "CHECKING ", module | |
pout = os.popen('pylint %s'% module, 'r') | |
for line in pout: | |
if "Your code has been rated at" in line: | |
print "PASSED pylint inspection: " + line | |
passed += 1 | |
return True | |
if "-error" in line: | |
print "FAILED pylint inspection: " + line | |
failed += 1 | |
return False | |
if __name__ == "__main__": | |
try: | |
print sys.argv | |
BASE_DIRECTORY = sys.argv[1] | |
except IndexError: | |
print "no directory specified, defaulting to current working directory" | |
BASE_DIRECTORY = os.getcwd() | |
print "looking for *.py scripts in subdirectories of ", BASE_DIRECTORY | |
for root, dirs, files in os.walk(BASE_DIRECTORY): | |
for name in files: | |
filepath = os.path.join(root, name) | |
check(filepath) | |
print "Passed: " + str(passed) + " Failed: " + str(failed) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment