[Patches] [ python-Patches-784089 ] A program to scan python files and list those require coding

SourceForge.net noreply at sourceforge.net
Thu Mar 3 16:42:57 CET 2005


Patches item #784089, was opened at 2003-08-06 14:47
Message generated for change (Comment added) made by phd
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=784089&group_id=5470

Category: Demos and tools
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Oleg Broytmann (phd)
Assigned to: Raymond Hettinger (rhettinger)
Summary: A program to scan python files and list those require coding

Initial Comment:
A program to scan python files (recursively) and list
those that require coding directive (pseudocomment)
because there non-ASCII characters in the file
(including comments).

The program treats files as python files if the
extension is .py or there is "python" in the first line
of the file.


----------------------------------------------------------------------

>Comment By: Oleg Broytmann (phd)
Date: 2005-03-03 18:42

Message:
Logged In: YES 
user_id=4799

Sorry for my poor English. "Can have" and "may have"...

----------------------------------------------------------------------

Comment By: Oleg Broytmann (phd)
Date: 2005-03-03 18:41

Message:
Logged In: YES 
user_id=4799

Thank you for pointing the regex. I fixed both programs.

But you are wrong about .py extension. A python module
really can only has .py extension, but a python program may
has any, for example, .cgi, or no extension at all.

----------------------------------------------------------------------

Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-03-03 18:35

Message:
Logged In: YES 
user_id=1188172

Also, perhaps there could be another mode of operation in
which the files in question are checked if they need an
encoding declaration anyways.

----------------------------------------------------------------------

Comment By: Reinhold Birkenfeld (birkenfeld)
Date: 2005-03-03 18:18

Message:
Logged In: YES 
user_id=1188172

The script only checks for "-*- coding", while the docs
state that the correct regex is "coding[=:]\s*([-\w.]+)".

In the pysource.py, I don't know if it is useful to open the
file and check the first line for "python". Normally, Python
files should be given the extension .py, so there is a great
probability of false positives.

----------------------------------------------------------------------

Comment By: Oleg Broytmann (phd)
Date: 2004-12-17 22:52

Message:
Logged In: YES 
user_id=4799

Added pysource.py module and an alternative implementation
using the module. The pysource.py module is, probably, of a
general interest and can be added to the standard library.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-10-20 10:04

Message:
Logged In: YES 
user_id=80475

Will make a few cleanups, replace the recursion and fileext
guessing to a glob.glob format, and will add to Tools/scripts.

----------------------------------------------------------------------

Comment By: Oleg Broytmann (phd)
Date: 2004-10-07 11:49

Message:
Logged In: YES 
user_id=4799

And don't forget to make it executable.

----------------------------------------------------------------------

Comment By: A.M. Kuchling (akuchling)
Date: 2004-08-08 01:50

Message:
Logged In: YES 
user_id=11375

So, does something need to be done with this script, like adding it to the 
distribution?


----------------------------------------------------------------------

Comment By: M.-A. Lemburg (lemburg)
Date: 2003-08-06 16:36

Message:
Logged In: YES 
user_id=38388

Thanks.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=784089&group_id=5470


More information about the Patches mailing list