pychecking current source file in pythonwin

H

Henrik Weber

Hi.

I have tried to add pychecker as an extension to pythonwin. Now I can
have pychecker check the source file that is currently open in the
editor with a single keypress. If someone is interested, here is how
to do it:

Create an empty file in your
<pythondir>\Lib\site-packages\Pythonwin\pywin directory. Give it a
name with .cfg as extension.

Into this file put the following lines (replace <pythondir> with the
path to your python installation):

[General]
Based On = Default
[Keys:Editor]
Shift+Ctrl+v = checksource
[Extensions]
def checksource(editor_window, event):
import pywin.framework.scriptutils
import os
import re

filename = pywin.framework.scriptutils.GetActiveFileName()
messages = os.popen(r"<pythondir>\Scripts\pychecker.bat %s" %
filename)
for message in messages.xreadlines():
print re.sub(r"(.*):(\d+):(.*)", r'File "\1", line \2, \3',
message.strip())
messages.close()



Start pythonwin. In the View menu select Options. Go to the Editor
tab. In the dropdown box select the name of your configuration file.
Click OK.

Now open a Python source file and press Shift+Ctrl+v. The output of
the operation can be found on the interactive screen. The script
formats the output so a double click on a pychecker message will jump
to the corresponding line in the editor.

The script should write something like "pychecker is checking your
source" into the status bar, but I haven't found out how to do that
yet. Maybe some helpful soul can help out with that.
 
H

Henrik Weber

Mark Hammond said:
Cool. Would you be interested in sending me a patch file? This makes
it much easier for me to integrate properly.


win32ui.SetStatusText(message, True)

Mark.

I hope it arrived.

Henrik.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,785
Latest member
undedgini

Latest Threads

Top