Created
June 6, 2012 09:51
-
-
Save reinhrst/2881003 to your computer and use it in GitHub Desktop.
epylint -- use pylint with emacs, with google app engine in path
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/env python | |
import re | |
import sys | |
from subprocess import * | |
PYTHONPATH = check_output('/usr/bin/find /Applications/GoogleAppEngineLauncher.app//Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/ -depth 1 -type d -exec /bin/echo -n "{}:" \;', shell=True) | |
PYTHONPATH += '/Applications/GoogleAppEngineLauncher.app//Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/'; | |
p = Popen(["/usr/local/bin/pylint","-fparseable","-rn","--disable=C,R", | |
sys.argv[1]], | |
stdout = PIPE, | |
env = {"PYTHONPATH": PYTHONPATH} | |
).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() |
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
(when (load "flymake" t) | |
(defun flymake-pylint-init () | |
(let* ((temp-file (flymake-init-create-temp-buffer-copy | |
'flymake-create-temp-inplace)) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) | |
(list "~/Dropbox/bin/epylint.py" (list local-file)))) | |
(add-to-list 'flymake-allowed-file-name-masks | |
'("\\.py\\'" flymake-pylint-init)) | |
) | |
(add-hook 'python-mode-hook | |
(lambda () (flymake-mode t))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspiration and blatant copying from http://emacswiki.org/emacs/PythonProgrammingInEmacs