Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | :mod:`tabnanny` --- Detection of ambiguous indentation |
| 2 | ====================================================== |
| 3 | |
| 4 | .. module:: tabnanny |
| 5 | :synopsis: Tool for detecting white space related problems in Python source files in a |
| 6 | directory tree. |
| 7 | .. moduleauthor:: Tim Peters <tim_one@users.sourceforge.net> |
| 8 | .. sectionauthor:: Peter Funk <pf@artcom-gmbh.de> |
| 9 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 10 | .. rudimentary documentation based on module comments |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 11 | |
| 12 | For the time being this module is intended to be called as a script. However it |
| 13 | is possible to import it into an IDE and use the function :func:`check` |
| 14 | described below. |
| 15 | |
Georg Brandl | e720c0a | 2009-04-27 16:20:50 +0000 | [diff] [blame] | 16 | .. note:: |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 17 | |
Georg Brandl | e720c0a | 2009-04-27 16:20:50 +0000 | [diff] [blame] | 18 | The API provided by this module is likely to change in future releases; such |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 19 | changes may not be backward compatible. |
| 20 | |
| 21 | |
| 22 | .. function:: check(file_or_dir) |
| 23 | |
| 24 | If *file_or_dir* is a directory and not a symbolic link, then recursively |
| 25 | descend the directory tree named by *file_or_dir*, checking all :file:`.py` |
Georg Brandl | 6911e3c | 2007-09-04 07:15:32 +0000 | [diff] [blame] | 26 | files along the way. If *file_or_dir* is an ordinary Python source file, it |
| 27 | is checked for whitespace related problems. The diagnostic messages are |
| 28 | written to standard output using the :func:`print` function. |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 29 | |
| 30 | |
| 31 | .. data:: verbose |
| 32 | |
| 33 | Flag indicating whether to print verbose messages. This is incremented by the |
| 34 | ``-v`` option if called as a script. |
| 35 | |
| 36 | |
| 37 | .. data:: filename_only |
| 38 | |
| 39 | Flag indicating whether to print only the filenames of files containing |
| 40 | whitespace related problems. This is set to true by the ``-q`` option if called |
| 41 | as a script. |
| 42 | |
| 43 | |
| 44 | .. exception:: NannyNag |
| 45 | |
| 46 | Raised by :func:`tokeneater` if detecting an ambiguous indent. Captured and |
| 47 | handled in :func:`check`. |
| 48 | |
| 49 | |
| 50 | .. function:: tokeneater(type, token, start, end, line) |
| 51 | |
| 52 | This function is used by :func:`check` as a callback parameter to the function |
| 53 | :func:`tokenize.tokenize`. |
| 54 | |
Christian Heimes | 5b5e81c | 2007-12-31 16:14:33 +0000 | [diff] [blame] | 55 | .. XXX document errprint, format_witnesses, Whitespace, check_equal, indents, |
| 56 | reset_globals |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 57 | |
| 58 | |
| 59 | .. seealso:: |
| 60 | |
| 61 | Module :mod:`tokenize` |
| 62 | Lexical scanner for Python source code. |