Table of Contents

Class: TextFormatter .\imports\TextFormatter.py

Formats text into columns.

Constructor takes a list of dictionaries that each specify the properties for a column. Dictionary entries can be:

width the width within which the text will be wrapped alignment left|center|right margin amount of space to prefix in front of column

The compose() method takes a list of strings and returns a formatted string consisting of each string wrapped within its respective column.

Example:

formatter = TextFormatter( ( {'width': 10}, {'width': 12, 'margin': 4}, {'width': 20, 'margin': 8, 'alignment': right}, ) )

print formatter.compose( ( "A rather short paragraph", "Here is a paragraph containing a veryveryverylongwordindeed.", "And now for something on the right-hand side.", ) )

gives:

A rather Here is a And now for short paragraph something on the paragraph containing a right-hand side. veryveryvery longwordinde ed.

Methods   
__init__
compose
  __init__ 
__init__ ( self,  colspeclist )

  compose 
compose ( self,  textlist )

Exceptions   
IndexError, "Number of text items does not match columns"

Table of Contents

This document was automatically generated on Thu Feb 06 22:28:50 2003 by HappyDoc version 2.1