pychecking current source file in pythonwin

Discussion in 'Python' started by Henrik Weber, Aug 5, 2003.

  1. Henrik Weber

    Henrik Weber Guest

    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.
     
    Henrik Weber, Aug 5, 2003
    #1
    1. Advertising

  2. Henrik Weber

    Henrik Weber Guest

    Mark Hammond <> wrote in message news:<bgpe2u$fmq$>...
    > 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.
     
    Henrik Weber, Aug 7, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manu
    Replies:
    1
    Views:
    6,104
    Natty Gur
    Jul 20, 2003
  2. Cloud Burst
    Replies:
    11
    Views:
    1,034
  3. stephan
    Replies:
    0
    Views:
    438
    stephan
    Jul 30, 2003
  4. Marek Prerovsky
    Replies:
    1
    Views:
    583
    python
    Feb 16, 2005
  5. Replies:
    2
    Views:
    302
Loading...

Share This Page