To my horror, someone pointed out to me yesterday that a web app I
wrote has been prominently displaying a misspelled word. The word was
buried in my code.
Is there a utility out there that will help spell-check literal
strings entered into Python source code? I don't mean spell-check
strings entered by the user; I mean, go through the .py file, isolate
strings, and tell me when the strings contain misspelled words. In an
ideal world, my IDE would do this with a red wavy line.
I guess a second-best thing would be an easy technique to open a .py
file and isolate all strings in it.
(I know that the better practice is to isolate user-displayed strings
from the code, but in this case that just didn't happen.) 9 3687
John Zenger wrote:
To my horror, someone pointed out to me yesterday that a web app I
wrote has been prominently displaying a misspelled word. The word was
buried in my code.
Is there a utility out there that will help spell-check literal
strings entered into Python source code? I don't mean spell-check
strings entered by the user; I mean, go through the .py file, isolate
strings, and tell me when the strings contain misspelled words. In an
ideal world, my IDE would do this with a red wavy line.
I guess a second-best thing would be an easy technique to open a .py
file and isolate all strings in it.
(I know that the better practice is to isolate user-displayed strings
from the code, but in this case that just didn't happen.)
Use the re module, identify the strings and write them to another file,
then open the file with your spell checker. Program shouldn't be more
than 10 lines.
(I know that the better practice is to isolate user-displayed strings
from the code, but in this case that just didn't happen.)
Use the re module, identify the strings and write them to another file,
then open the file with your spell checker. Program shouldn't be more
than 10 lines.
Have a look at the tokenize python module for the regular expressions
for extracting strings (for all possible Python string formats). On a
Debian box you can find it here: /usr/lib/python2.4/tokenize.py
It would probably be simpler to hack a copy of that script so it
writes all the strings in your source to a text file, which you then
spellcheck.
Another method would be to log all the strings your web app writes, to
a text file, then run through your entire site, and then spellcheck
your logfile.
David wrote:
>>(I know that the better practice is to isolate user-displayed strings from the code, but in this case that just didn't happen.)
Use the re module, identify the strings and write them to another file, then open the file with your spell checker. Program shouldn't be more than 10 lines.
Have a look at the tokenize python module for the regular expressions
for extracting strings (for all possible Python string formats). On a
Debian box you can find it here: /usr/lib/python2.4/tokenize.py
It would probably be simpler to hack a copy of that script so it
writes all the strings in your source to a text file, which you then
spellcheck.
Another method would be to log all the strings your web app writes, to
a text file, then run through your entire site, and then spellcheck
your logfile.
Nice module :
import tokenize
def processStrings(type, token, (srow, scol), (erow, ecol), line):
if tokenize.tok_name[type] == 'STRING' :
print tokenize.tok_name[type], token, \
(srow, scol), (erow, ecol), line
file = open("myprogram.py")
tokenize.tokenize(
file.readline,
processStrings
)
How would you go about writing the output to a file? I mean, I would
like to open the file at main level and pass a handle to the file to
processStrings to write to it, finally close output file at main level.
Probably a class with a processString method?
On Sat, 08 Sep 2007 14:04:55 -0700, John Zenger <jo********@gmail.com>
wrote:
In an ideal world, my IDE would do this with a red wavy line.
I can't help with your problem, but this is the first thing I turn off in
Word. It drives me _mad_.
Sorry - just had to share that.
DaveM
John Zenger writes:
In an ideal world, my IDE would do this with a red wavy line.
You didn't mention which IDE you use; however, if you use Emacs, there
is flyspell-prog-mode which does that for you (checks your spelling
"on the fly", but only within comments and strings).
Regards,
David Trudgett
--
These are not the droids you are looking for. Move along.
>In an ideal world, my IDE would do this with a red wavy line.
>
You didn't mention which IDE you use; however, if you use Emacs, there
is flyspell-prog-mode which does that for you (checks your spelling
"on the fly", but only within comments and strings).
Same in Vim (:set spell)
HTH,
--
Miki <mi*********@gmail.com> http://pythonwise.blogspot.com
tokenize.tokenize(
file.readline,
processStrings
)
How would you go about writing the output to a file? I mean, I would
like to open the file at main level and pass a handle to the file to
processStrings to write to it, finally close output file at main level.
Probably a class with a processString method?
tokenize.tokenize() takes a callable object as it's second arg. So you
can use a class which you construct with the file, and you give it an
appropriate __call__ method. http://docs.python.org/ref/callable-types.html
Although with a short script a global var may be simpler.
On Sep 8, 4:04 pm, John Zenger <johnzen...@gmail.comwrote:
To my horror, someone pointed out to me yesterday that a web app I
wrote has been prominently displaying a misspelled word. The word was
buried in my code.
Is there a utility out there that will help spell-check literal
strings entered into Python source code? I don't mean spell-check
strings entered by the user; I mean, go through the .py file, isolate
strings, and tell me when the strings contain misspelled words. In an
ideal world, my IDE would do this with a red wavy line.
I guess a second-best thing would be an easy technique to open a .py
file and isolate all strings in it.
(I know that the better practice is to isolate user-displayed strings
from the code, but in this case that just didn't happen.)
This is when it's good to use put all your UI strings in a file and
get the advantages of spelling checking ease and the ability to
translate the app.
On 9/9/07, David <wi******@gmail.comwrote:
tokenize.tokenize(
file.readline,
processStrings
)
How would you go about writing the output to a file? I mean, I would
like to open the file at main level and pass a handle to the file to
processStrings to write to it, finally close output file at main level.
Probably a class with a processString method?
You can also use closures for this. http://ivan.truemesh.com/archives/000411.html
See the example in the "Assignment considered awkward" section. Since
you're not assigning to your file variable in processStrings you don't
have to use the list work-around mentioned later in the doc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steve Jorgensen |
last post by:
There's this app I wrote a long time ago for a client who uses it to
administer the database content that drives their Web site. Last time I was
in there' I notices a lot of embarassing typos in...
|
by: Bhupesh Naik |
last post by:
This is a query regarding my problem to make a spell and
grammar check possible in text area of a web page.
We have aspx pages which are used to construct letters.
The browser based screens...
|
by: ACaunter |
last post by:
Hi all,
I was wondering if there is a Spell Checker for asp.net.. i have found a
bunch written in vb.net or c#, but i'm having trouble bringing it over into a
web application from a windows...
|
by: Jason L James |
last post by:
Dear all,
I have an app that captures text entry from
the user and stores it in an SQL DB. I want
to make sure that the text is spelt correctly
using a spell checked; possibly the one...
|
by: LowRyder |
last post by:
I haven't been able to find any fixes for this. I have a form with two
memo fields. Sometimes when you push the spell check button or press
F7 the spell check goes into an infinite loop. If you...
|
by: Owen Jenkins |
last post by:
I have an application that I distribute as a 97 or 2000 mde. If the
client has A2000/2/3, he uses the 2000 version. If he has 97, he uses
the 97 version. If he has neither, he uses the 97 runtime....
|
by: dinoo |
last post by:
I would appreciate if some one can help me out.
We are using Microsoft Word's spell check functionality in one of our web
pages based on the requirement. We are using Microsoft PIA assemblies to...
|
by: jamesnkk |
last post by:
I have seen posting on Spell check problem, but seem like not solution. Therefore I post this question again.
How can I spell check on one record and on one field such as Notes in my Form. MS...
|
by: =?Utf-8?B?UGF1bA==?= |
last post by:
I was just wondering if anyone has implimented any of the free spell check
tools for .net web applications and if they found it difficult? Also just
wondering if anyone can recommend any good...
|
by: Mike |
last post by:
I have an app running at a client where, when the spell checker is
supposed to run, it reports "Can't start spell checker because it is
not installed".
I have never had this before - it works...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
|
by: SueHopson |
last post by:
Hi All,
I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
| |