Jack Jansen | b5ec5e4 | 2000-11-29 10:02:22 +0000 | [diff] [blame^] | 1 | Original README for Tabcleaner.py |
| 2 | |
| 3 | tabcleaner.py is a utility that reformats leading whitespace in a Python source. |
| 4 | It uses tokenize.py (from the std distribution) to detect INDENTs and DEDENTs, |
| 5 | then reformats according to the user's options (tabs-only, spaces-only with |
| 6 | indent size n, or mixed with tab worth m and indent level of n). |
| 7 | |
| 8 | Python does not care about the indent of comments and multi-linestrings. |
| 9 | tabcleaner places these at what Python considers the current indentlevel. About |
| 10 | half the time, this is correct; the rest of the time it is probably one indent |
| 11 | level less than what was desired. It is pretty much guaranteed to be |
| 12 | syntactically correct, (earlier versions broke on some triple-quoted strings). |
| 13 | |
| 14 | With no args, (or "-h") prints usage text. |
| 15 | |
| 16 | Contact: gmcm@hypernet.com |
| 17 | |
| 18 | Additional comments: I have made a few slight changes. It was written to take |
| 19 | command line arguments, so that you can set parameters like the size of indents, |
| 20 | and whether you want the result to be all tabs, or all spaces, or a mixture of |
| 21 | both (an evil combination, if you ask me). It is set, be default, to change your |
| 22 | indentation to all tabs. |
| 23 | |
| 24 | In the current version of Python, all the code in the standard library is |
| 25 | indented with only spaces. This is a somewhat awkward standard on the mac, so |
| 26 | most MacPython code is indented with only tabs. This script can be used to do any |
| 27 | version, but all tabs is the default, which seems to be the best option for the |
| 28 | Mac. |
| 29 | |
| 30 | How to use it on a Mac: |
| 31 | |
| 32 | The script is set up to take filenames (or directory names) on the command line. |
| 33 | To simulate this behaviour with MacPython, you can build an applet out of it |
| 34 | (with BuildApplet, which should be in your Python folder). Any files draggged and |
| 35 | dropped onto the resulting applet will be converted to all tabs, with a backup |
| 36 | copy havning been saved. |
| 37 | |
| 38 | If you want the script to convert to space based indentation, your best bet is |
| 39 | probably to change the default on line 46 of the file. |
| 40 | |
| 41 | -Chris Barker cbarker@jps.net |