| Home | Trees | Index | Help |
|
|---|
| Package SCons :: Package compat :: Module _scons_textwrap :: Class TextWrapper |
|
Object for wrapping/filling text. The public interface consists of the wrap() and fill() methods; the other methods are just there for subclasses to override in order to tweak the default behaviour. If you want to completely replace the main wrapping algorithm, you'll probably have to override _wrap_chunks().
| Method Summary | |
|---|---|
__init__(self,
width,
initial_indent,
subsequent_indent,
expand_tabs,
replace_whitespace,
fix_sentence_endings,
break_long_words)
| |
_fix_sentence_endings(chunks : [string]) | |
cur_line : [string], cur_len : int, width : int) | |
_munge_whitespace(text : string) -> string | |
_split(text : string) -> [string] Split the text to wrap into indivisible chunks. | |
_wrap_chunks(chunks : [string]) -> [string] | |
fill(text : string) -> string | |
wrap(text : string) -> [string] | |
| Class Variable Summary | |
|---|---|
SRE_Pattern |
sentence_end_re = [abcdefghijklmnopqrstuvwxyz][\.!\?]["'...
|
dict |
unicode_whitespace_trans = {32: 32, 9: 32, 10: 32, 11: 3...
|
int |
uspace = 32 |
str |
whitespace_trans = '\x00\x01\x02\x03\x04\x05\x06\x07\x08...
|
SRE_Pattern |
wordsep_re = (\s+|-*\w{2,}-(?=\w{2,}))
|
int |
x = 32 |
| Method Details |
|---|
_fix_sentence_endings(self, chunks)_fix_sentence_endings(chunks : [string]) Correct for sentence endings buried in 'chunks'. Eg. when the original text contains "... foo.
|
_handle_long_word(self, chunks, cur_line, cur_len, width)
Handle a chunk of text (most likely a word, not whitespace) that is too long to fit in any line. |
_munge_whitespace(self, text)_munge_whitespace(text : string) -> string Munge whitespace in text: expand tabs and convert all other whitespace characters to spaces. Eg. " foo bar
|
_split(self, text)_split(text : string) -> [string] Split the text to wrap into indivisible chunks. Chunks are not quite the same as words; see wrap_chunks() for full details. As an example, the text Look, goof-ball -- use the -b option! breaks into the following chunks: 'Look,', ' ', 'goof-', 'ball', ' ', '--', ' ', 'use', ' ', 'the', ' ', '-b', ' ', 'option!' |
_wrap_chunks(self, chunks)_wrap_chunks(chunks : [string]) -> [string] Wrap a sequence of text chunks and return a list of lines of length 'self.width' or less. (If 'break_long_words' is false, some lines may be longer than this.) Chunks correspond roughly to words and the whitespace between them: each chunk is indivisible (modulo 'break_long_words'), but a line break can come between any two chunks. Chunks should not have internal whitespace; ie. a chunk is either all whitespace or a "word". Whitespace chunks will be removed from the beginning and end of lines, but apart from that whitespace is preserved. |
fill(self, text)fill(text : string) -> string Reformat the single paragraph in 'text' to fit in lines of no more than 'self.width' columns, and return a new string containing the entire wrapped paragraph. |
wrap(self, text)wrap(text : string) -> [string] Reformat the single paragraph in 'text' so it fits in lines of no more than 'self.width' columns, and return a list of wrapped lines. Tabs in 'text' are expanded with string.expandtabs(), and all other whitespace characters (including newline) are converted to space. |
| Class Variable Details |
|---|
sentence_end_re
|
unicode_whitespace_trans
|
uspace
|
wordsep_re
|
x
|
| Home | Trees | Index | Help |
|
|---|
| Generated by Epydoc 2.1 on Wed Dec 12 09:39:31 2007 | http://epydoc.sf.net |