Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +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 | |
Georg Brandl | b19be57 | 2007-12-29 10:57:00 +0000 | [diff] [blame] | 10 | .. rudimentary documentation based on module comments |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 11 | |
Éric Araujo | 29a0b57 | 2011-08-19 02:14:03 +0200 | [diff] [blame] | 12 | **Source code:** :source:`Lib/tabnanny.py` |
| 13 | |
| 14 | -------------- |
| 15 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 16 | For the time being this module is intended to be called as a script. However it |
| 17 | is possible to import it into an IDE and use the function :func:`check` |
| 18 | described below. |
| 19 | |
Georg Brandl | 16a57f6 | 2009-04-27 15:29:09 +0000 | [diff] [blame] | 20 | .. note:: |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 21 | |
Georg Brandl | 16a57f6 | 2009-04-27 15:29:09 +0000 | [diff] [blame] | 22 | The API provided by this module is likely to change in future releases; such |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 23 | changes may not be backward compatible. |
| 24 | |
| 25 | |
| 26 | .. function:: check(file_or_dir) |
| 27 | |
| 28 | If *file_or_dir* is a directory and not a symbolic link, then recursively |
| 29 | descend the directory tree named by *file_or_dir*, checking all :file:`.py` |
| 30 | files along the way. If *file_or_dir* is an ordinary Python source file, it is |
| 31 | checked for whitespace related problems. The diagnostic messages are written to |
| 32 | standard output using the print statement. |
| 33 | |
| 34 | |
| 35 | .. data:: verbose |
| 36 | |
| 37 | Flag indicating whether to print verbose messages. This is incremented by the |
| 38 | ``-v`` option if called as a script. |
| 39 | |
| 40 | |
| 41 | .. data:: filename_only |
| 42 | |
| 43 | Flag indicating whether to print only the filenames of files containing |
| 44 | whitespace related problems. This is set to true by the ``-q`` option if called |
| 45 | as a script. |
| 46 | |
| 47 | |
| 48 | .. exception:: NannyNag |
| 49 | |
| 50 | Raised by :func:`tokeneater` if detecting an ambiguous indent. Captured and |
| 51 | handled in :func:`check`. |
| 52 | |
| 53 | |
| 54 | .. function:: tokeneater(type, token, start, end, line) |
| 55 | |
| 56 | This function is used by :func:`check` as a callback parameter to the function |
| 57 | :func:`tokenize.tokenize`. |
| 58 | |
Georg Brandl | b19be57 | 2007-12-29 10:57:00 +0000 | [diff] [blame] | 59 | .. XXX document errprint, format_witnesses, Whitespace, check_equal, indents, |
| 60 | reset_globals |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 61 | |
| 62 | |
| 63 | .. seealso:: |
| 64 | |
| 65 | Module :mod:`tokenize` |
| 66 | Lexical scanner for Python source code. |