[Zope-Checkins] reindent.py (Was: CVS: Zope/ZServer - FCGIServer.py:1.19)

Martijn Pieters mj@zope.com
Wed, 14 Aug 2002 16:31:48 -0400


On Wed, Aug 14, 2002 at 04:11:30PM -0400, Tim Peters wrote:
> Probably not:  -tt doesn't actually warn about tabs, it warns only when both
> tabs and spaces appear at the starts of lines, and in a way such that the
> relative (wrt the preceding line) indentation differs if you think "tabs are
> 4 spaces" than if you think "tabs are 8 spaces".

Which is pretty good for most cases. :)

> In the Python codebase, I routinely run tools/scripts/redindent.py.  This
> gets rid of all hard tabs (believing "tabs are 8 spaces"), normalizes all
> indentation levels to 4 spaces per indent, nukes trailing whitespace from
> lines, and trims trailing empty lines from files.  It works much harder than
> similar tools to preserve intended indentation of comments relative to
> source code.  It hasn't screwed up -- yet <wink>.

Running it with -drv indeed shows plenty of changes to be made, but it blows
up with:

checking ./ZServer/medusa/test/max_sockets.py ...
Traceback (most recent call last):
  File "/usr/share/doc/python2.1/examples/Tools/scripts/reindent.py", line
258, in ?
    main()
  File "/usr/share/doc/python2.1/examples/Tools/scripts/reindent.py", line
65, in main
    check(arg)
  File "/usr/share/doc/python2.1/examples/Tools/scripts/reindent.py", line
77, in check
    check(fullname)
  File "/usr/share/doc/python2.1/examples/Tools/scripts/reindent.py", line
77, in check
    check(fullname)
  File "/usr/share/doc/python2.1/examples/Tools/scripts/reindent.py", line
77, in check
    check(fullname)
  File "/usr/share/doc/python2.1/examples/Tools/scripts/reindent.py", line
77, in check
    check(fullname)
  File "/usr/share/doc/python2.1/examples/Tools/scripts/reindent.py", line
90, in check
    if r.run():
  File "/usr/share/doc/python2.1/examples/Tools/scripts/reindent.py", line
174, in run
    want = have + getlspace(after[jline-1]) - \
IndexError: list index out of range

This is in a Zope 2.5 branch checkout, with Python 2.1.3 and the Python
2.1.3 version of the script..

-- 
Martijn Pieters
| Software Engineer  mailto:mj@zope.com
| Zope Corporation   http://www.zope.com/
| Creators of Zope   http://www.zope.org/
---------------------------------------------