Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

alternative epylint
Monday, February 15th, 2010 at 11:39:31pm UTC 

  1. #!/usr/bin/env python
  2.  
  3. import re
  4. import sys
  5.  
  6. from subprocess import Popen, PIPE
  7.  
  8. ignore = ",".join ( [
  9.     "C0103"# Naming convention
  10.     "I0011"# Warning locally suppressed using disable-msg
  11.     "I0012"# Warning locally suppressed using disable-msg
  12.     "W0511"# FIXME/TODO
  13.     "W0142"# *args or **kwargs magic.
  14.     "R0904"# Too many public methods
  15.     "R0201"# Method could be a function
  16. ] )
  17.  
  18. cmd = "pylint --output-format parseable --include-ids y --reports n --disable-msg=%s %s" % \
  19.     ( ignore, sys.argv[1], )
  20.  
  21. p = Popen ( cmd, shell = True, bufsize = -1,
  22.             stdin = PIPE, stdout = PIPE, stderr = PIPE, close_fds = True )
  23.  pylint_re = re.compile (
  24.     '^([^:]+):(\d+):\s*\[([WECR])([^,]+),\s*([^\]]+)\]\s*(.*)$'
  25.     )
  26.  for line in p.stdout:
  27.     line = line.strip()
  28.     m = pylint_re.match ( line )
  29.     if m:
  30.         filename, linenum, errtype, errnum, context, description = m.groups()
  31.          if errtype == "E":
  32.             msg = "Error"
  33.         else:
  34.             msg = "Warning"
  35.         # Here we are targetting the following flymake regexp:
  36.         #
  37.         #  ("\\(.*\\) at \\([^ \n]+\\) line \\([0-9]+\\)[,.\n]" 2 3 nil 1)
  38.         #
  39.         # where the number at the end indicate the index into the regexp
  40.         # groups of ( file, line, column, error text )
  41.         #
  42.         # You can see what regexps flymake uses to parse its output by   
  43.         # running 'M-x describe-variable' on the variable
  44.         # 'flymake-err-line-patterns'
  45.    
  46.         print "%s %s%s %s at %s line %s." % ( msg, errtype, errnum,
  47.                                                   description, filename, linenum )

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right worth-right