Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
textwrap.cpython-314.pyc212 linesDownload Raw Back to __pycache__
1+
2��i�K���Rt^RIt.ROtRt!RR4tR
RltR
RltRtRtRR	lt	]3R48Xd]!]!R44R#R#)zText wrapping and filling.5N�TextWrapperz	6
 c�a�]tRt^toRt]P
]!]]	4]!R44t7RtRtR]
P!]	4,tR]R,,t]
P"!RR	]R8]R]R]/,]
P$4tAAA]
P"!R
],4tA]
P"!R4tRRRRR/RlltRtRtRtRtRtRtRtRtRtVt R#)rab9Object for wrapping/filling text.  The public interface consists of10the wrap() and fill() methods; the other methods are just there for11subclasses to override in order to tweak the default behaviour.12If you want to completely replace the main wrapping algorithm,13you'll probably have to override _wrap_chunks().14 15Several instance attributes control various aspects of wrapping:16  width (default: 70)17    the maximum width of wrapped lines (unless break_long_words18    is false)19  initial_indent (default: "")20    string that will be prepended to the first line of wrapped21    output.  Counts towards the line's width.22  subsequent_indent (default: "")23    string that will be prepended to all lines save the first24    of wrapped output; also counts towards each line's width.25  expand_tabs (default: true)26    Expand tabs in input text to spaces before further processing.27    Each tab will become 0 .. 'tabsize' spaces, depending on its position28    in its line.  If false, each tab is treated as a single character.29  tabsize (default: 8)30    Expand tabs in input text to 0 .. 'tabsize' spaces, unless31    'expand_tabs' is false.32  replace_whitespace (default: true)33    Replace all whitespace characters in the input text by spaces34    after tab expansion.  Note that if expand_tabs is false and35    replace_whitespace is true, every tab will be converted to a36    single space!37  fix_sentence_endings (default: false)38    Ensure that sentence-ending punctuation is always followed39    by two spaces.  Off by default because the algorithm is40    (unavoidably) imperfect.41  break_long_words (default: true)42    Break words longer than 'width'.  If false, those words will not43    be broken, and some lines might be longer than 'width'.44  break_on_hyphens (default: true)45    Allow breaking hyphenated words. If true, wrapping will occur46    preferably on whitespaces and right after hyphens part of47    compound words.48  drop_whitespace (default: true)49    Drop leading and trailing whitespace from lines.50  max_lines (default: None)51    Truncate wrapped lines.52  placeholder (default: ' [...]')53    Append to the last line of truncated text.54� z[\w!"\'&.,?]z[^\d\W]z[%s]z[^:�NNa�55        ( # any whitespace56          %(ws)s+57        | # em-dash between words58          (?<=%(wp)s) -{2,} (?=\w)59        | # word, possibly hyphenated60          %(nws)s+? (?:61            # hyphenated word62              -(?: (?<=%(lt)s{2}-) | (?<=%(lt)s-%(lt)s-))63              (?= %(lt)s -? %(lt)s)64            | # end of word65              (?=%(ws)s|\z)66            | # em-dash67              (?<=%(wp)s) (?=-{2,}\w)68            )69        )�wp�lt�ws�nwsz(%s+)z[a-z][\.\!\?][\"\']?\z�	max_linesN�placeholderz [...]c��WnW nW0nW@nWPnW`nWpnW�nW�nW�n	W�n70W�nR#�N)�width�initial_indent�subsequent_indent�expand_tabs�replace_whitespace�fix_sentence_endings�break_long_words�drop_whitespace�break_on_hyphens�tabsizer71r)
�selfrrrrrrrrrrr72rs
&&&&&&&&&&&$$�Lib\textwrap.py�__init__�TextWrapper.__init__psI���73�,��!2��&��"4��$8�!� 0��.�� 0����"��&��c��VP'dVPVP4pVP'dVP	VP744pV#)z�_munge_whitespace(text : string) -> string75 76Munge whitespace in text: expand tabs and convert all other77whitespace characters to spaces.  Eg. " foo\tbar\n\nbaz"78becomes " foo    bar  baz".79)r�80expandtabsrr�	translate�unicode_whitespace_trans�r�texts&&r�_munge_whitespace�TextWrapper._munge_whitespace�sG�������?�?�4�<�<�0�D��"�"�"��>�>�$�"?�"?�@�D��rc���VPRJdVPPV4pMVPPV4pVUu.uFq3'gKVNK	ppV#uupi)a�_split(text : string) -> [string]81 82Split the text to wrap into indivisible chunks.  Chunks are83not quite the same as words; see _wrap_chunks() for full84details.  As an example, the text85  Look, goof-ball -- use the -b option!86breaks into the following chunks:87  'Look,', ' ', 'goof-', 'ball', ' ', '--', ' ',88  'use', ' ', 'the', ' ', '-b', ' ', 'option!'89if break_on_hyphens is True, or in:90  'Look,', ' ', 'goof-ball', ' ', '--', ' ',91  'use', ' ', 'the', ' ', '-b', ' ', option!'92otherwise.93T)r�94wordsep_re�split�wordsep_simple_re)rr"�chunks�cs&&  r�_split�TextWrapper._split�s^��� � �D�(��_�_�*�*�4�0�F��+�+�1�1�$�7�F�#�)�V��q�!�!�V��)��
��*s�	A$�A$c���^pVPPpV\V4^,958dJW^,,R8Xd+V!W,4'dRW^,&V^,
pKUV^,
pK`R#)a7_fix_sentence_endings(chunks : [string])96 97Correct for sentence endings buried in 'chunks'.  Eg. when the98original text contains "... foo.\nBar ...", munge_whitespace()99and split() will convert that to [..., "foo.", " ", "Bar", ...]100which has one too few spaces; this method simply changes the one101space to two.102rz  N)�sentence_end_re�search�len)rr)�i�	patsearchs&&  r�_fix_sentence_endings�!TextWrapper._fix_sentence_endings�sf��
���(�(�/�/�	��#�f�+�a�-����c�{�c�!�i��	�&:�&:�"���s���Q����Q��� rc��V^8d^pMWC,103pVP'd�V^8�d�TpVR,pVP'dt\V4V8�ddVPR^V4pV^8�dJ\;QJdRVRV4F'gKRM	RM!RVRV44'd104V^,pVPVRV4WvRVR&R#V'g"VPVP
44R#R#)z�_handle_long_word(chunks : [string],105                     cur_line : [string],106                     cur_len : int, width : int)107 108Handle a chunk of text (most likely a word, not whitespace) that109is too long to fit in any line.110�-c3�*"�TF	qR8gx�K	R#5i)r6N�)�.0r*s& r�	<genexpr>�0TextWrapper._handle_long_word.<locals>.<genexpr>�s���%G��1�3�h��s�NTF�����)rrr0�rfind�any�append�pop)	r�reversed_chunks�cur_line�cur_lenr�111space_left�end�chunk�hyphens	&&&&&    r�_handle_long_word�TextWrapper._handle_long_word�s����1�9��J���J�� � � �Z�!�^��C�#�B�'�E��$�$�$��U��j�)@����S�!�Z�8���A�:�#�#�%G��g�v��%G�#�#�#�%G��g�v��%G�"G�"G� �1�*�C��O�O�E�$�3�K�(�"'��+�O�B��112��O�O�O�/�/�1�2�rc�^�.pVP^8:d\RVP,4hVPexVP^8�dVPpMVPp\V4\VPP44,VP8�d\R4hVP4V'Ed`.p^pV'dVPpMVPpVP\V4,113pVP'd(VR,P4R8XdV'dVRV'dJ\VR,4pWW,V8:d*VPVP44WW,
pKPV'dC\VR,4V8�d,VPWWV4\\\114V44pVP'dAV'd9VR,P4R8XdV\VR,4,pVRV'gEK{VPeo\V4^,VP8gNV'd@VP'd^\V4^8XdNV^,P4'g1WV8:d+VPVRP!V4,4EK!V'd�VR,P4'dhV\VP4,V8:dGVPVP4VPVRP!V4,4V#V\VR,4,pVRK�V'ddVR,P#4p\V4\VP4,VP8:dW�P,VR&V#VPW0PP4,4V#V#)aO_wrap_chunks(chunks : [string]) -> [string]115 116Wrap a sequence of text chunks and return a list of lines of117length 'self.width' or less.  (If 'break_long_words' is false,118some lines may be longer than this.)  Chunks correspond roughly119to words and the whitespace between them: each chunk is120indivisible (modulo 'break_long_words'), but a line break can121come between any two chunks.  Chunks should not have internal122whitespace; ie. a chunk is either all whitespace or a "word".123Whitespace chunks will be removed from the beginning and end of124lines, but apart from that whitespace is preserved.125zinvalid width %r (must be > 0)z#placeholder too large for max width�r<)r�126ValueErrorr127rrr0r�lstrip�reverser�stripr?r@rH�sum�map�join�rstrip)	rr)�lines�indentrBrCr�l�	prev_lines	&&       r�_wrap_chunks�TextWrapper._wrap_chunks�s!�����:�:��?��=��128�129�J�K�K��>�>�%��~�~��!��/�/���,�,���6�{�S��!1�!1�!8�!8�!:�;�;�d�j�j�H� �!F�G�G�	�����f��H��G���/�/���,�,���J�J��V��,�E��#�#�#��r�130�(8�(8�(:�b�(@�U��2�J����r�131�O���;�%�'��O�O�F�J�J�L�1��L�G���#�f�R�j�/�E�1��&�&�v��H��c�#�x�0�1���#�#�#��X�b�\�5G�5G�5I�R�5O��3�x��|�,�,���R�L��x��N�N�*���J��N�T�^�^�3���)�)�)���[�A�%������*�*��0@��L�L��"�'�'�(�*;�!;�<�"�$�R�L�.�.�0�0�#�c�$�*:�*:�&;�;�u�D�$�O�O�D�,<�,<�=�!�L�L��"�'�'�(�2C�)C�D�!���� �3�x��|�#4�4��$�R�L� �(-�b�	�(8�(8�(:�I� #�I���T�5E�5E�1F� F�$(�J�J�!/�,5�8H�8H�,H��b�	� %������V�.>�.>�.E�.E�.G�%G�H����u�rc�F�VPV4pVPV4#r
)r#r+r!s&&r�
_split_chunks�TextWrapper._split_chunksUs!���%�%�d�+���{�{�4� � rc��VPV4pVP'dVPV4VPV4#)a.wrap(text : string) -> [string]132 133Reformat the single paragraph in 'text' so it fits in lines of134no more than 'self.width' columns, and return a list of wrapped135lines.  Tabs in 'text' are expanded with string.expandtabs(),136and all other whitespace characters (including newline) are137converted to space.138)r[rr3rX)rr"r)s&& r�wrap�TextWrapper.wrap[s?���#�#�D�)���$�$�$��&�&�v�.�� � ��(�(rc�B�RPVPV44#)z�fill(text : string) -> string139 140Reformat the single paragraph in 'text' to fit in lines of no141more than 'self.width' columns, and return a new string142containing the entire wrapped paragraph.143�144)rRr^r!s&&r�fill�TextWrapper.fillis���y�y����4��)�)r)rrrrrrr145rrrrr)146�FrKrKTTFTTT�)!�__name__�147__module__�__qualname__�__firstlineno__�__doc__�dict�fromkeysrQ�ord�_whitespacer �148word_punct�letter�re�escape�149whitespace�nowhitespace�compile�VERBOSEr&r(r.rr#r+r3rHrXr[r^rb�__static_attributes__�__classdictcell__)�
__classdict__s@rrrs����.�` $�}�}�S��k�-B�C��H�M��!�J�
�F��2�9�9�[�1�1�J��*�R�.�(�L����
��j�$���j�%��7�7�"	�150�151�#�J�$	�F�L��152�153�8�j�#8�9����j�j�"'�(�O�154'� �'�&�'�>��,�$!3�Re�N!�)�*�*rc�>�\RRV/VBpVPV4#)a�Wrap a single paragraph of text, returning a list of wrapped lines.155 156Reformat the single paragraph in 'text' so it fits in lines of no157more than 'width' columns, and return a list of wrapped lines.  By158default, tabs in 'text' are expanded with string.expandtabs(), and159all other whitespace characters (including newline) are converted to160space.  See TextWrapper class for available keyword args to customize161wrapping behaviour.162rr8)rr^�r"r�kwargs�ws&&, rr^r^us$��	�*�%�*�6�*�A��6�6�$�<�rc�>�\RRV/VBpVPV4#)a~Fill a single paragraph of text, returning a new string.163 164Reformat the single paragraph in 'text' to fit in lines of no more165than 'width' columns, and return a new string containing the entire166wrapped paragraph.  As with wrap(), tabs are expanded and other167whitespace characters converted to space.  See TextWrapper class for168available keyword args to customize wrapping behaviour.169rr8)rrbr{s&&, rrbrb�s$��	�*�%�*�6�*�A��6�6�$�<�rc��\RRVR^/VBpVPRPVP4P	444#)a�Collapse and truncate the given text to fit in the given width.170 171The text first has its whitespace collapsed.  If it then fits in172the *width*, it is returned as is.  Otherwise, as many words173as possible are joined and then the placeholder is appended::174 175    >>> textwrap.shorten("Hello  world!", width=12)176    'Hello world!'177    >>> textwrap.shorten("Hello  world!", width=11)178    'Hello [...]'179rr180rr8)rrbrRrOr'r{s&&, r�shortenr��sB��	�7�%�7�1�7��7�A��6�6�#�(�(�4�:�:�<�-�-�/�0�1�1rc��VPR4pTUu.uF&q3'gKTP4'dK$TNK(	pp\
TRR7p\TRR7p^p\T4FwrxY�T,8wg181TR9gKM	RPTUu.uFq3P4'gY7RMRNK 	up4# \\3d'R\T4P:2p\T4Rhi;iuupiuupi)a�Remove any common leading whitespace from every line in `text`.182 183This can be used to make triple-quoted strings line up with the left184edge of the display, while still presenting them in the source code185in indented form.186 187Note that tabs and spaces are both treated as whitespace, but they188are not equal: the lines "  hello" and "\thello" are189considered to have no common leading whitespace.190 191Entirely blank lines are normalized to a newline character.192razexpected str object, not NrK)�defaultz 	)193r'�AttributeError�	TypeError�typerh�isspace�min�max�	enumeraterR)	r"rT�msgrV�non_blank_lines�l1�l2�marginr*s	&        r�dedentr��s���'��194�195�4� ��#(�A�%�Q�1�q�Q�Y�Y�[�q�q�%�O�A�	�_�b�	)�B�	�_�b�	)�B�
�F��r�]�	���6�196�?�a�u�n��#��9�9�U�K�U��	�	���a��j��;�U�K�L�L��
�I�&�'�)�$�t�*�*A�*A�)D�E����n�$�&�'��197B��Ls �C�	C?�C?�C?�$D�7C<c�b�.pVfRVPR4F;pVP4'gVPV4VPV4K=	MHVPR4F3pV!V4'dVPV4VPV4K5	RPV4#)a2Adds 'prefix' to the beginning of selected lines in 'text'.198 199If 'predicate' is provided, 'prefix' will only be added to the lines200where 'predicate(line)' is True. If 'predicate' is not provided,201it will default to adding 'prefix' to all non-empty lines that do not202consist solely of whitespace characters.203TrK)�204splitlinesr�r?rR)r"�prefix�	predicate�prefixed_lines�lines&&&  rrUrU�s����N����O�O�D�)�D��<�<�>�>��%�%�f�-��!�!�$�'�*�205�O�O�D�)�D������%�%�f�-��!�!�$�'�*��7�7�>�"�"r�__main__z Hello there.206  This is indented.)rr^rbr�rUr�)rdr
)rjrq�__all__rnrr^rbr�r�rUrf�printr8rr�<module>r�sa���207�208H��209 ��_*�_*�H�210�
2�$M�>#�2�z��211�&�4�2125�6�r
codekingpro/portable-devtools · Team Ai