mirror of https://github.com/python/cpython
42 lines
1.9 KiB
Plaintext
42 lines
1.9 KiB
Plaintext
Original README for Tabcleaner.py
|
|
|
|
tabcleaner.py is a utility that reformats leading whitespace in a Python source.
|
|
It uses tokenize.py (from the std distribution) to detect INDENTs and DEDENTs,
|
|
then reformats according to the user's options (tabs-only, spaces-only with
|
|
indent size n, or mixed with tab worth m and indent level of n).
|
|
|
|
Python does not care about the indent of comments and multi-linestrings.
|
|
tabcleaner places these at what Python considers the current indentlevel. About
|
|
half the time, this is correct; the rest of the time it is probably one indent
|
|
level less than what was desired. It is pretty much guaranteed to be
|
|
syntactically correct, (earlier versions broke on some triple-quoted strings).
|
|
|
|
With no args, (or "-h") prints usage text.
|
|
|
|
Contact: gmcm@hypernet.com
|
|
|
|
Additional comments: I have made a few slight changes. It was written to take
|
|
command line arguments, so that you can set parameters like the size of indents,
|
|
and whether you want the result to be all tabs, or all spaces, or a mixture of
|
|
both (an evil combination, if you ask me). It is set, be default, to change your
|
|
indentation to all tabs.
|
|
|
|
In the current version of Python, all the code in the standard library is
|
|
indented with only spaces. This is a somewhat awkward standard on the mac, so
|
|
most MacPython code is indented with only tabs. This script can be used to do any
|
|
version, but all tabs is the default, which seems to be the best option for the
|
|
Mac.
|
|
|
|
How to use it on a Mac:
|
|
|
|
The script is set up to take filenames (or directory names) on the command line.
|
|
To simulate this behaviour with MacPython, you can build an applet out of it
|
|
(with BuildApplet, which should be in your Python folder). Any files draggged and
|
|
dropped onto the resulting applet will be converted to all tabs, with a backup
|
|
copy havning been saved.
|
|
|
|
If you want the script to convert to space based indentation, your best bet is
|
|
probably to change the default on line 46 of the file.
|
|
|
|
-Chris Barker cbarker@jps.net
|