pychecking current source file in pythonwin

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Henrik Weber

    pychecking current source file in pythonwin

    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\Python win\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(edi tor_window, event):
    import pywin.framework .scriptutils
    import os
    import re

    filename = pywin.framework .scriptutils.Ge tActiveFileName ()
    messages = os.popen(r"<pyt hondir>\Scripts \pychecker.bat %s" %
    filename)
    for message in messages.xreadl ines():
    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.
  • Henrik Weber

    #2
    Re: pychecking current source file in pythonwin

    Mark Hammond <mhammond@skipp inet.com.au> wrote in message news:<bgpe2u$fm [email protected] yrinth.net.au>. ..[color=blue]
    > Henrik Weber wrote:
    >[color=green]
    > > 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:[/color]
    >
    > Cool. Would you be interested in sending me a patch file? This makes
    > it much easier for me to integrate properly.
    >[color=green]
    > > 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.[/color]
    >
    > win32ui.SetStat usText(message, True)
    >
    > Mark.[/color]

    I hope it arrived.

    Henrik.

    Comment

    Working...