pychecking current source file in pythonwin

13 views
Skip to first unread message

Henrik Weber

unread,
Aug 5, 2003, 8:41:12 AM8/5/03
to
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.

Mark Hammond

unread,
Aug 5, 2003, 7:20:05 PM8/5/03
to
Henrik Weber wrote:

> 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:

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

> 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.

win32ui.SetStatusText(message, True)

Mark.

Henrik Weber

unread,
Aug 7, 2003, 4:00:57 AM8/7/03
to
Mark Hammond <mham...@skippinet.com.au> wrote in message news:<bgpe2u$fmq$2...@arachne.labyrinth.net.au>...

I hope it arrived.

Henrik.

Reply all
Reply to author
Forward
0 new messages