P.S. Others may want to contribute the appropriate expressions for their particular language...
Regular Expression to match error ouput for Python
---------------------------------------------------------------
Here is the regex Regular Expression you need in order to match error ouput for Python TextPad use. When you run Python on a file, and get an error - you will now be able to double click on the error line (the one with a line number in it) and TextPad will jump you to that line in the source code.
Configure>Preferences>Tools>Python>
^.*"\([^"]+\)", line \([0-9]+\)
(of course you had to create this run tool)
Configure>Preferences>Tools>Add
Command C:\Python22\python.exe
Param $File
Initial folder $FileDir
_________________
-Andy Bulka
http://www.atug.com/andypatterns
Regular Expression regex to match error ouput
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Using this RE:
^.*"\([^"]+\)", line \([0-9]+\)
I get a :
Cannot jump to item under cursor.
Error. Here is the output in the command window.
File "C:\prj\metron\socket\msg2server.py", line 31
return command + " bar":
^
SyntaxError: invalid syntax
Tool completed with exit code 1
Did I miss something?
Chuck
^.*"\([^"]+\)", line \([0-9]+\)
I get a :
Cannot jump to item under cursor.
Error. Here is the output in the command window.
File "C:\prj\metron\socket\msg2server.py", line 31
return command + " bar":
^
SyntaxError: invalid syntax
Tool completed with exit code 1
Did I miss something?
Chuck
Using this RE:
Make sure you double click on the line with the filename in it, not the line with the error itself.
-Andy Bulka
http://www.atug.com/andypatterns
http://www.atug.com/andypatterns
python jump-to behaviour
Mmm - well I don't know. The expression you entered seems right. It works for me. I have textpad 4.6.2 as well.
The file
--------------- junk.py
def A():
pass
blah
sdfs
dsd
fsd
fsd
ff
sd
------------
when I run python 2.2 on it, generates the output
-------------------
Traceback (most recent call last):
File "C:\Documents and Settings\Administrator\Desktop\junk.py", line 6, in ?
blah
NameError: name 'blah' is not defined
Tool completed with exit code 1
-------------------
and when I double click on the line with the word File in it, the jump behaviour works.
ANOTHER THOUGHT
Looking at your error message, the only difference I see is that mine says
... \junk.py", line 6, in ?
and yours says
...\msg2server.py", line 31
notice that yours doesn't have the phrase
, in ?
maybe that is what is causing the problem. Are you running python 2.2 under windows, which is what I am doing. Perhaps the regular expression needs to be tweaked to handle this slight difference in the formatting of the python interpreter ouput.
Since I cannot generate the exact output you are getting (command output windows are read only) I can't experiment around with regular expressions.
Let us know what happens.
-Andy
The file
--------------- junk.py
def A():
pass
blah
sdfs
dsd
fsd
fsd
ff
sd
------------
when I run python 2.2 on it, generates the output
-------------------
Traceback (most recent call last):
File "C:\Documents and Settings\Administrator\Desktop\junk.py", line 6, in ?
blah
NameError: name 'blah' is not defined
Tool completed with exit code 1
-------------------
and when I double click on the line with the word File in it, the jump behaviour works.
ANOTHER THOUGHT
Looking at your error message, the only difference I see is that mine says
... \junk.py", line 6, in ?
and yours says
...\msg2server.py", line 31
notice that yours doesn't have the phrase
, in ?
maybe that is what is causing the problem. Are you running python 2.2 under windows, which is what I am doing. Perhaps the regular expression needs to be tweaked to handle this slight difference in the formatting of the python interpreter ouput.
Since I cannot generate the exact output you are getting (command output windows are read only) I can't experiment around with regular expressions.
Let us know what happens.
-Andy
-Andy Bulka
http://www.atug.com/andypatterns
http://www.atug.com/andypatterns
After a bit of screwing around I got the following to work:
^ File .*"\([^"]+\)"[,] line \([0-9]+\)
I'm running python 2.2.2.
FWIW the way I figured it out was to copy the line:
File "C:\prj\metron\socket\msg2server.py", line 31
Over and over in an editor and then to use the replace dialog to experiment with RE's until it worked. This is the first one that worked so there might be better. The comma is what seemed to mess things up. I had to put [,] to get it to work...
Thanks for your help.
Chuck
^ File .*"\([^"]+\)"[,] line \([0-9]+\)
I'm running python 2.2.2.
FWIW the way I figured it out was to copy the line:
File "C:\prj\metron\socket\msg2server.py", line 31
Over and over in an editor and then to use the replace dialog to experiment with RE's until it worked. This is the first one that worked so there might be better. The comma is what seemed to mess things up. I had to put [,] to get it to work...
Thanks for your help.
Chuck
I have experienced an oddity with this functionality in Textpad. I developed an RE for decoding PC-Lint error lines of the default form (Lint actually allows the error line format to be programmable):
D:\Projects\Troya\Software\Src\Opto.c 73 Error 10: Expecting identifier
using:
^\([A-Za-z0-9:\\\.]+\) \([0-9]+\)
This wouldn't jump to the line initially. After all sorts of playing around, it suddenly started working. Now I didn't change the expression at all. There seems to be a problem with textpad not recognising it immediately - maybe try closing textpad and re-opening???
D:\Projects\Troya\Software\Src\Opto.c 73 Error 10: Expecting identifier
using:
^\([A-Za-z0-9:\\\.]+\) \([0-9]+\)
This wouldn't jump to the line initially. After all sorts of playing around, it suddenly started working. Now I didn't change the expression at all. There seems to be a problem with textpad not recognising it immediately - maybe try closing textpad and re-opening???