I've found it! It appears that just formatting the output in a certain way 
will get the results into the BBEdit 'error' window. I'm attaching my script 
and have also made a Gist for it. Requires the Python file to be saved 
first.

https://gist.github.com/1157742

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
#!/usr/bin/env python2.6
"""
A quick script to install into your `Application Support/BBEdit/Scripts` folder.
This runs PyFlakes (requires PyFlakes to be installed at `/usr/local/bin` -
try ``/usr/bin/easy_install-2.6 pyflakes==0.4.0``) and reformats the results
so that they show up in BBEdit's search results / error / warnings window. Then
the errors can be stepped through one at a time.

I've bound this to control-shift-V. You must save your Python file first before
running the check.
"""
from __future__ import print_function
import os
import re
import sys
from subprocess import Popen, PIPE

doc_file = os.environ['BB_DOC_PATH']
pyflakes = "/usr/local/bin/pyflakes"

out, err = Popen([pyflakes, doc_file], stdout=PIPE, stderr=PIPE).communicate()
if out:
    output = out
else:
    output = err

if not output:
    sys.exit(0)

line_format = re.compile('(?P<path>[^:]+):(?P<line>\d+):\s(?P<message>.*$)')
for line in output.splitlines():
    m = line_format.match(line)
    if not m:
        continue
    groups = m.groupdict()
    print('''  File "{path}", line {line}'''.format(**groups), file=sys.stderr)
    print(groups['message'], file=sys.stderr)
    print('^', file=sys.stderr)

sys.exit(1)

Reply via email to