By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,825 Members | 1,258 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,825 IT Pros & Developers. It's quick & easy.

pychecking current source file in pythonwin

P: n/a
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.
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Mark Hammond <mh******@skippinet.com.au> wrote in message news:<bg**********@arachne.labyrinth.net.au>...
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.


I hope it arrived.

Henrik.
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.