2018-05-03 15:10:55 +03:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
|
|
|
# Runs pylint on all python scripts found in a directory tree
|
|
|
|
# Reference: http://rowinggolfer.blogspot.com/2009/08/pylint-recursively.html
|
|
|
|
|
2019-01-22 03:20:27 +03:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2018-05-03 15:10:55 +03:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
def check(filepath):
|
|
|
|
if filepath.endswith(".py"):
|
2018-06-10 00:38:00 +03:00
|
|
|
content = open(filepath, "rb").read()
|
|
|
|
|
2018-05-03 15:10:55 +03:00
|
|
|
if "\n\n\n" in content:
|
|
|
|
index = content.find("\n\n\n")
|
2019-01-22 03:20:27 +03:00
|
|
|
print(filepath, repr(content[index - 30:index + 30]))
|
2018-05-03 15:10:55 +03:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
try:
|
|
|
|
BASE_DIRECTORY = sys.argv[1]
|
|
|
|
except IndexError:
|
2019-01-22 03:20:27 +03:00
|
|
|
print("no directory specified, defaulting to current working directory")
|
2018-05-03 15:10:55 +03:00
|
|
|
BASE_DIRECTORY = os.getcwd()
|
|
|
|
|
2019-01-22 03:20:27 +03:00
|
|
|
print("looking for *.py scripts in subdirectories of '%s'" % BASE_DIRECTORY)
|
2018-05-03 15:10:55 +03:00
|
|
|
for root, dirs, files in os.walk(BASE_DIRECTORY):
|
|
|
|
if any(_ in root for _ in ("extra", "thirdparty")):
|
|
|
|
continue
|
|
|
|
for name in files:
|
|
|
|
filepath = os.path.join(root, name)
|
|
|
|
check(filepath)
|