-
-
Save jeansch/6615215 to your computer and use it in GitHub Desktop.
Invoke Pep8, pylint and pyflakes.
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/python | |
# Invoke Pep8, pylint and pyflakes. | |
import sys | |
from pkg_resources import load_entry_point | |
from pyflakes.scripts.pyflakes import main as pyflakes_main | |
import re | |
from subprocess import * | |
if __name__ == "__main__": | |
# Pep8 | |
from pep8 import StyleGuide | |
pep8style = StyleGuide(parse_argv=True, config_file=True) | |
report = pep8style.check_files() | |
# Pylint | |
p = Popen("pylint -f parseable -r n %s" % | |
sys.argv[1], shell = True, stdout = PIPE).stdout | |
for line in p: | |
match = re.search("\\[([WE])(, (.+?))?\\]", line) | |
if match: | |
kind = match.group(1) | |
func = match.group(3) | |
if kind == "W": | |
msg = "Warning" | |
else: | |
msg = "Error" | |
if func: | |
line = re.sub("\\[([WE])(, (.+?))?\\]", | |
"%s (%s):" % (msg, func), line) | |
else: | |
line = re.sub("\\[([WE])?\\]", "%s:" % msg, line) | |
print line, | |
p.close() | |
# Pyflakes | |
pyflakes_main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment