pychecking current source file in pythonwin

Henrik Weber Henrik.Weber at sdm.de
Tue Aug 5 08:41:12 EDT 2003


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.




More information about the Python-list mailing list