Skip to content

Instantly share code, notes, and snippets.

@reinhrst
Created June 6, 2012 09:51
Show Gist options
  • Save reinhrst/2881003 to your computer and use it in GitHub Desktop.
Save reinhrst/2881003 to your computer and use it in GitHub Desktop.
epylint -- use pylint with emacs, with google app engine in path
#!/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()
(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)))
@reinhrst
Copy link
Author

reinhrst commented Jun 6, 2012

Inspiration and blatant copying from http://emacswiki.org/emacs/PythonProgrammingInEmacs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment