ACC SHELL
Path : /usr/lib/python/ |
|
Current File : //usr/lib/python/textwrap.pyo |
Ńň
oÄMc @ sş d Z d Z d d k Z d d k Z d d d d g Z d Z d f d YZ d
d Z d
d Z e i d
e i
Z e i d e i
Z d Z
e d j o e
d GHn d S( s Text wrapping and filling.
s: $Id: textwrap.py 68135 2009-01-01 15:46:10Z georg.brandl $i˙˙˙˙Nt TextWrappert wrapt fillt dedents
c B s÷ e Z d Z e i e d e e Z h Z e d Z
x! e e e D] Z e
e e <qJ We
i d Z e
i d Z e
i d e i Z d d d e e e e e e d Z d Z d
Z d Z d Z d
Z d Z d Z RS( s÷
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().
Several instance attributes control various aspects of wrapping:
width (default: 70)
the maximum width of wrapped lines (unless break_long_words
is false)
initial_indent (default: "")
string that will be prepended to the first line of wrapped
output. Counts towards the line's width.
subsequent_indent (default: "")
string that will be prepended to all lines save the first
of wrapped output; also counts towards each line's width.
expand_tabs (default: true)
Expand tabs in input text to spaces before further processing.
Each tab will become 1 .. 8 spaces, depending on its position in
its line. If false, each tab is treated as a single character.
replace_whitespace (default: true)
Replace all whitespace characters in the input text by spaces
after tab expansion. Note that if expand_tabs is false and
replace_whitespace is true, every tab will be converted to a
single space!
fix_sentence_endings (default: false)
Ensure that sentence-ending punctuation is always followed
by two spaces. Off by default because the algorithm is
(unavoidably) imperfect.
break_long_words (default: true)
Break words longer than 'width'. If false, those words will not
be broken, and some lines might be longer than 'width'.
break_on_hyphens (default: true)
Allow breaking hyphenated words. If true, wrapping will occur
preferably on whitespaces and right after hyphens part of
compound words.
drop_whitespace (default: true)
Drop leading and trailing whitespace from lines.
t u sL (\s+|[^\s\w]*\w+[^0-9\W]-(?=\w+[^0-9\W])|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))s (\s+)s [%s][\.\!\?][\"\']?\ZiF t c
C s | | _ | | _ | | _ | | _ | | _ | | _ | | _ | | _ | | _ t i
| i i t i
| _ t i
| i i t i
| _ d S( N( t widtht initial_indentt subsequent_indentt expand_tabst replace_whitespacet fix_sentence_endingst break_long_wordst drop_whitespacet break_on_hyphenst ret compilet
wordsep_ret patternt Ut wordsep_re_unit wordsep_simple_ret wordsep_simple_re_uni(
t selfR R R R R
R R R
R ( ( s /usr/lib/python2.6/textwrap.pyt __init__k s
c C sx | i o | i } n | i oP t | t o | i | i } qt t | t o | i | i } qt n | S( sÚ _munge_whitespace(text : string) -> string
Munge whitespace in text: expand tabs and convert all other
whitespace characters to spaces. Eg. " foo bar
baz"
becomes " foo bar baz".
( R t
expandtabsR
t
isinstancet strt translatet whitespace_transt unicodet unicode_whitespace_trans( R t text( ( s /usr/lib/python2.6/textwrap.pyt _munge_whitespace s
c C sv t | t o$ | i o
| i } qT | i } n! | i o
| i } n
| i } | i | } t d | } | S( sM _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!'
if break_on_hyphens is True, or in:
'Look,', ' ', 'goof-ball', ' ', '--', ' ',
'use', ' ', 'the', ' ', '-b', ' ', option!'
otherwise.
N(
R R R R R R R t splitt filtert None( R R t patt chunks( ( s /usr/lib/python2.6/textwrap.pyt _split s
c C s d } | i } xk | t | d j oS | | d d j o0 | i | | o d | | d <| d 7} q | d 7} q Wd S( sf _fix_sentence_endings(chunks : [string])
Correct for sentence endings buried in 'chunks'. Eg. when the
original text contains "... foo.
Bar ...", munge_whitespace()
and split() will convert that to [..., "foo.", " ", "Bar", ...]
which has one too few spaces; this method simply changes the one
space to two.
i i R s i N( t sentence_end_ret lent search( R R&