Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #! /usr/bin/env python
  2. '''
  3. Author: gregorynicholas (github), modified by Jacob Henderson (jacohend, github)
  4. Module that runs pylint on all python scripts found in a directory tree..
  5. '''
  6.  
  7. import os
  8. import re
  9. import sys
  10.  
  11. passed = 0
  12. failed = 0
  13.  
  14. def check(module):
  15. global passed, failed
  16. '''
  17. apply pylint to the file specified if it is a *.py file
  18. '''
  19. if module[-3:] == ".py":
  20.  
  21. print "CHECKING ", module
  22. pout = os.popen('pylint %s'% module, 'r')
  23. for line in pout:
  24. if "Your code has been rated at" in line:
  25. print "PASSED pylint inspection: " + line
  26. passed += 1
  27. return True
  28. if "-error" in line:
  29. print "FAILED pylint inspection: " + line
  30. failed += 1
  31. return False
  32.  
  33. if __name__ == "__main__":
  34. try:
  35. print sys.argv
  36. BASE_DIRECTORY = sys.argv[1]
  37. except IndexError:
  38. print "no directory specified, defaulting to current working directory"
  39. BASE_DIRECTORY = os.getcwd()
  40.  
  41. print "looking for *.py scripts in subdirectories of ", BASE_DIRECTORY
  42. for root, dirs, files in os.walk(BASE_DIRECTORY):
  43. for name in files:
  44. filepath = os.path.join(root, name)
  45. check(filepath)
  46. print "Passed: " + str(passed) + " Failed: " + str(failed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement