Package SCons :: Package compat :: Module _scons_textwrap
[show private | hide private]
[frames | no frames]

Module SCons.compat._scons_textwrap

Text wrapping and filling.

Classes
TextWrapper Object for wrapping/filling text.

Function Summary
  dedent(text)
dedent(text : string) -> string Remove any whitespace than can be uniformly removed from the left of every line in `text`.
  fill(text, width, **kwargs)
Fill a single paragraph of text, returning a new string.
  wrap(text, width, **kwargs)
Wrap a single paragraph of text, returning a list of wrapped lines.

Function Details

dedent(text)

dedent(text : string) -> string

    Remove any whitespace than can be uniformly removed from the left
    of every line in `text`.

    This can be used e.g. to make triple-quoted strings line up with
    the left edge of screen/whatever, while still presenting it in the
    source code in indented form.

    For example:

        def test():
            # end first line with \ to avoid the empty line!
            s = '''            hello
              world
            '''
            print repr(s)          # prints '    hello
      world
    '
            print repr(dedent(s))  # prints 'hello
  world
'

fill(text, width=70, **kwargs)

Fill a single paragraph of text, returning a new string.

Reformat the single paragraph in 'text' to fit in lines of no more than 'width' columns, and return a new string containing the entire wrapped paragraph. As with wrap(), tabs are expanded and other whitespace characters converted to space. See TextWrapper class for available keyword args to customize wrapping behaviour.

wrap(text, width=70, **kwargs)

Wrap a single paragraph of text, returning a list of wrapped lines.

Reformat the single paragraph in 'text' so it fits in lines of no more than 'width' columns, and return a list of wrapped lines. By default, tabs in 'text' are expanded with string.expandtabs(), and all other whitespace characters (including newline) are converted to space. See TextWrapper class for available keyword args to customize wrapping behaviour.


Generated by Epydoc 2.1 on Wed Dec 12 09:39:32 2007 http://epydoc.sf.net