Created
May 28, 2016 11:41
-
-
Save snoack/7889063520fb8efdff7077b9090d6bdb 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
import sys | |
import re | |
import os | |
try: | |
from StringIO import StringIO | |
except ImportError: | |
from io import StringIO | |
import flake8.engine | |
def make_putty_ignores(paths): | |
style_guide = flake8.engine.get_style_guide() | |
orig_stdout = sys.stdout | |
sys.stdout = stdout = StringIO() | |
try: | |
style_guide.check_files(paths) | |
finally: | |
sys.stdout = orig_stdout | |
files = {} | |
stdout.seek(0) | |
for line in stdout: | |
filename, error = re.search('^([^:]*):\d+:\d+: (\S+)', line).groups() | |
files.setdefault(os.path.normpath(filename), set()).add(error) | |
for filename in sorted(files): | |
print('{} : {}'.format(filename, ','.join(sorted(files[filename])))) | |
if __name__ == '__main__': | |
make_putty_ignores(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment