Current Path : /compat/linux/proc/self/root/usr/local/lib/python2.5/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //compat/linux/proc/self/root/usr/local/lib/python2.5/textwrap.pyc |
³ò h”Rc @ sí d Z d Z d d k Z d d k Z y e e f Wn% e j o d d f \ Z Z n Xd 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. s8 $Id: textwrap.py 46863 2006-06-11 19:42:51Z tim.peters $iÿÿÿÿNi i t TextWrappert wrapt fills 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 e i ƒ Z d d d 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'. t u sL (\s+|[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))s [%s][\.\!\?][\"\']?iF t c C sC | | _ | | _ | | _ | | _ | | _ | | _ | | _ d S( N( t widtht initial_indentt subsequent_indentt expand_tabst replace_whitespacet fix_sentence_endingst break_long_words( t selfR R R R R R R ( ( s$ /usr/local/lib/python2.5/textwrap.pyt __init__^ 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/local/lib/python2.5/textwrap.pyt _munge_whitespacer s c C s% | i i | ƒ } t d | ƒ } | S( s£ _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!' N( t wordsep_ret splitt filtert None( R R t chunks( ( s$ /usr/local/lib/python2.5/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 t it pat( ( s$ /usr/local/lib/python2.5/textwrap.pyt _fix_sentence_endings’ s )c C sj t | | d ƒ } | i o+ | i | d | ƒ | d | | d <n | p | i | i ƒ ƒ n d S( s _handle_long_word(chunks : [string], cur_line : [string], cur_len : int, width : int) Handle a chunk of text (most likely a word, not whitespace) that is too long to fit in any line. i iÿÿÿÿN( t maxR t appendt pop( R t reversed_chunkst cur_linet cur_lenR t space_left( ( s$ /usr/local/lib/python2.5/textwrap.pyt _handle_long_word¤ s c C s‡ g } | i d j o t d | i ƒ ‚ n | i ƒ xI| oAg } d } | o | i } n | i } | i t | ƒ } | d i ƒ d j o | o | d =n xO | oG t | d ƒ } | | | j o! | i | i ƒ ƒ | | 7} q© Pq© W| o1 t | d ƒ | j o | i | | | | ƒ n | o"