shell bypass 403
l
��bc @ s� d Z d d l Z d d l Z d d d d g Z d Z Gd � d � Z d d
� Z d d � Z e j d e j � Z
e j d
e j � Z d � Z e
d k r� e e d � � n d S( u Text wrapping and filling.
i Nu TextWrapperu wrapu fillu dedentu
c
B s� | Ee Z d Z i Z e d � Z x e D] Z e e e e � <q) We j d � Z
e j d � Z e j d � Z d d d d d d d d d d � Z d � Z d � Z d
� Z d � Z d � Z d
� Z d � Z d S( u�
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.
u uL (\s+|[^\s\w]*\w+[^0-9\W]-(?=\w+[^0-9\W])|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))u (\s+)u [a-z][\.\!\?][\"\']?\ZiF u c
C sU | | _ | | _ | | _ | | _ | | _ | | _ | | _ | | _ | | _ d S( N( u widthu initial_indentu subsequent_indentu expand_tabsu replace_whitespaceu fix_sentence_endingsu break_long_wordsu drop_whitespaceu break_on_hyphens(
u selfu widthu initial_indentu subsequent_indentu expand_tabsu replace_whitespaceu fix_sentence_endingsu break_long_wordsu drop_whitespaceu break_on_hyphens( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu __init__^ s
c C s: | j r | j � } n | j r6 | j | j � } n | S( u� _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".
( u expand_tabsu
expandtabsu replace_whitespaceu translateu unicode_whitespace_trans( u selfu text( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu _munge_whitespacev s
c C sJ | j d k r$ | j j | � } n | j j | � } d � | D� } | S( uN _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.
c S s g | ] } | r | � q S( ( ( u .0u c( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu
<listcomp>� s T( u break_on_hyphensu Trueu
wordsep_reu splitu wordsep_simple_re( u selfu textu chunks( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu _split� s
c C s| d } | j j } xc | t | � d k rw | | d d k rj | | | � rj d | | d <| d 7} q | d 7} q Wd S( uf _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 u u i N( u sentence_end_reu searchu len( u selfu chunksu iu patsearch( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu _fix_sentence_endings� s $
c C s~ | d k r d } n
| | } | j r^ | j | d d | � � | d | d � | d <n | sz | j | j � � n d S( u
_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 Ni����i����i����( u break_long_wordsu appendu pop( u selfu reversed_chunksu cur_lineu cur_lenu widthu
space_left( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu _handle_long_word� s
c C s� g } | j d k r+ t d | j � � n | j � xH| rg } d } | r\ | j } n | j } | j t | � } | j r� | d j � d k r� | r� | d =n xK | r� t | d � } | | | k r� | j | j � � | | 7} q� Pq� W| r*t | d � | k r*| j
| | | | � n | j rY| rY| d j � d k rY| d
=n | r8 | j | d j | � � q8 q8 W| S( u� _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.
i u invalid width %r (must be > 0)i u i����i����i����i����i����i����( u widthu
ValueErroru reverseu subsequent_indentu initial_indentu lenu drop_whitespaceu stripu appendu popu _handle_long_wordu join( u selfu chunksu linesu cur_lineu cur_lenu indentu widthu l( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu _wrap_chunks� s4
%
%
!c C sD | j | � } | j | � } | j r7 | j | � n | j | � S( u^ 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.
( u _munge_whitespaceu _splitu fix_sentence_endingsu _fix_sentence_endingsu _wrap_chunks( u selfu textu chunks( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu wrap s
c C s d j | j | � � S( u� 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.
u
( u joinu wrap( u selfu text( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu fill% s NTF( u __name__u
__module__u __doc__u unicode_whitespace_transu ordu uspaceu _whitespaceu xu reu compileu
wordsep_reu wordsep_simple_reu sentence_end_reu Trueu Falseu __init__u _munge_whitespaceu _splitu _fix_sentence_endingsu _handle_long_wordu _wrap_chunksu wrapu fill( u
__locals__( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu TextWrapper s2
(
! I iF c K s t d | | � } | j | � S( u� 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.
u width( u TextWrapperu wrap( u textu widthu kwargsu w( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu wrap1 s
c K s t d | | � } | j | � S( u� 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.
u width( u TextWrapperu fill( u textu widthu kwargsu w( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu fill> s u ^[ ]+$u (^[ ]*)(?:[^
])c C s� d } t j d | � } t j | � } xT | D]L } | d k rI | } q. | j | � r[ q. | j | � rs | } q. d } Pq. Wd r� | r� xF | j d � D]2 } | s� | j | � s� t d | | f � � q� Wn | r� t j d | d | � } n | S( u9 Remove any common leading whitespace from every line in `text`.
This can be used to make triple-quoted strings line up with the left
edge of the display, while still presenting them in the source code
in indented form.
Note that tabs and spaces are both treated as whitespace, but they
are not equal: the lines " hello" and " hello" are
considered to have no common leading whitespace. (This behaviour is
new in Python 2.5; older versions of this module incorrectly
expanded tabs before searching for common leading whitespace.)
u i u
u line = %r, margin = %ru (?m)^N( u Noneu _whitespace_only_reu subu _leading_whitespace_reu findallu
startswithu splitu AssertionErroru re( u textu marginu indentsu indentu line( ( u/ /usr/local/python-3.2/lib/python3.2/textwrap.pyu dedentP s&