Created
November 6, 2015 11:21
-
-
Save rshk/131c2a63a6adcc07ecda 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 subprocess | |
import sys | |
flake8 = ['flake8'] + sys.argv[1:] | |
proc = subprocess.Popen(flake8, stdout=subprocess.PIPE) | |
for line in proc.stdout: | |
filename, row, col, extra = [ | |
x.strip().decode('utf8') | |
for x in line.split(b':', 3)] | |
msgcolor = '2' | |
if extra[0] == 'E': | |
msgcolor = '1' | |
elif extra[0] == 'F': | |
msgcolor = '5' | |
elif extra[0] == 'W': | |
msgcolor = '3' | |
print("\x1b[1m{}\x1b[0;32m:{}\x1b[0;33m:{}\x1b[0m \x1b[3{}m{}\x1b[0m" | |
.format(filename, row, col, msgcolor, extra)) | |
blame = subprocess.check_output( | |
['git', 'blame', filename, '-L', '{0},{0}'.format(row)] | |
).strip().decode('utf8') | |
print(' {}'.format(blame)) | |
print('') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment