§
    cÌcl.  ã                   ód   — d dl Z d dlmZ ddlmZ g d¢Z G d„ de j        ¦  «        Zd
d„Z	d
d	„Z
dS )é    N)Úeast_asian_widthé   )Úosutils)ÚUTextWrapperÚfillÚwrapc                   óJ   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ ZdS )r   aŸ  
    Extend TextWrapper for Unicode.

    This textwrapper handles east asian double width and split word
    even if !break_long_words when word contains double width
    characters.

    :param ambiguous_width: (keyword argument) width for character when
                            unicodedata.east_asian_width(c) == 'A'
                            (default: 1)

    Limitations:
    * expand_tabs doesn't fixed. It uses len() for calculating width
      of string on left of TAB.
    * Handles one codeunit as a single character having 1 or 2 width.
      This is not correct when there are surrogate pairs, combined
      characters or zero-width characters.
    * Treats all asian character are line breakable. But it is not
      true because line breaking is prohibited around some characters.
      (For example, breaking before punctation mark is prohibited.)
      See UAX # 14 "UNICODE LINE BREAKING ALGORITHM"
    Nc                 ó6  — |€"t          j        ¦   «         pt           j        dz
  }|                     dd¦  «        }|dk    rd| _        n|dk    rd| _        nt          d¦  «        ‚|                     dd ¦  «        | _        t          j	        j
        | |fi |¤Ž d S )Nr   Úambiguous_widthÚFWé   ÚFWAz ambiguous_width should be 1 or 2Ú	max_lines)r   Úterminal_widthÚdefault_terminal_widthÚpopÚ_east_asian_doublewidthÚ
ValueErrorÚgetr   ÚtextwrapÚTextWrapperÚ__init__)ÚselfÚwidthÚkwargsÚ
ambi_widths       ú2/usr/lib/python3/dist-packages/breezy/utextwrap.pyr   zUTextWrapper.__init__:   s­   € Øˆ=ÝÔ+Ñ-Ô-ð 4ÝÔ3°qñ9ˆEð —Z’ZÐ 1°1Ñ5Ô5ˆ
Ø˜Š?ˆ?Ø+/ˆDÔ(Ð(Ø˜1Š_ˆ_Ø+0ˆDÔ(Ð(åÐ?Ñ@Ô@Ð@àŸš K°Ñ6Ô6ˆŒÝÔÔ% d¨EÐ<Ð<°VÐ<Ð<Ð<Ð<Ð<ó    c                 ó6   — t          |¦  «        | j        v rdpdS )z_Return width of character `uc`.

        :param:     uc      Single unicode character.
        r   r   )Ú_eawidthr   )r   Úucs     r   Ú_unicode_char_widthz UTextWrapper._unicode_char_widthJ   s"   € õ ˜‘” Ô <Ð<ÐBÀÐHÀqÐHr   c                 óH   ‡— | j         Št          ˆfd„|D ¦   «         ¦  «        S )z›Returns width for s.

        When s is unicode, take care of east asian width.
        When s is bytes, treat all byte is single width character.
        c              3   ó.   •K  — | ]} ‰|¦  «        V — Œd S ©N© )Ú.0ÚcÚ	charwidths     €r   ú	<genexpr>z&UTextWrapper._width.<locals>.<genexpr>[   s+   øè è € Ð+Ð+ A�9�9˜Q‘<”<Ð+Ð+Ð+Ð+Ð+Ð+r   )r"   Úsum)r   Úsr)   s     @r   Ú_widthzUTextWrapper._widthT   s0   ø€ ð Ô,ˆ	ÝÐ+Ð+Ð+Ð+¨Ð+Ñ+Ô+Ñ+Ô+Ð+r   c                 óš   — d}| j         }t          |¦  «        D ]/\  }}| ||¦  «        z  }||k    r|d|…         ||d…         fc S Œ0|dfS )znReturns head and rest of s. (head+rest == s)

        Head is large as long as _width(head) <= width.
        r   NÚ )r"   Ú	enumerate)r   r,   r   Úwr)   Úposr(   s          r   Ú_cutzUTextWrapper._cut]   st   € ð
 ˆØÔ,ˆ	Ý ‘l”lð 	(ð 	(‰FˆC�Ø��˜1‘”ÑˆAØ�5ŠyˆyØ˜˜#˜”w  # $ $¤Ð'Ð'Ð'Ð'ð à�"ˆuˆr   c                 óÈ   — d}t          |¦  «        dz
  }| j        j        }||k     r;||dz            dk    r |||         ¦  «        rd||dz   <   |dz  }n|dz  }||k     °9dS dS )aÐ  _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.

        Note: This function is copied from textwrap.TextWrap and modified
        to use unicode always.
        r   r   ú z  r   N)ÚlenÚsentence_end_reÚsearch)r   ÚchunksÚiÚLÚ	patsearchs        r   Ú_fix_sentence_endingsz"UTextWrapper._fix_sentence_endingsj   s†   € ð ˆÝ�‰KŒK˜!‰OˆØÔ(Ô/ˆ	Ø�!ŠeˆeØ�a˜!‘eŒ} Ò#Ð#¨	¨	°&¸´)Ñ(<Ô(<Ð#Ø $��q˜1‘u‘Ø�Q‘��à�Q‘�ð �!Šeˆeˆeˆeˆeˆer   c                 ó\  — |dk     r,|d         r!|                       |d         d         ¦  «        pd}n||z
  }| j        rB|                      |d         |¦  «        \  }}|                     |¦  «         |r||d<   d S |d= d S |s)|                     |                     ¦   «         ¦  «         d S d S )Nr   éÿÿÿÿr   r   )r-   Úbreak_long_wordsr3   Úappendr   )r   r9   Úcur_lineÚcur_lenr   Ú
space_leftÚheadÚrests           r   Ú_handle_long_wordzUTextWrapper._handle_long_word€   sÍ   € ð �1Š9ˆ9Ø œÐB¨¯ª°F¸2´J¸q´MÑ(BÔ(BÐGÀaˆJˆJà ™ˆJð Ô ð 	*ØŸš 6¨"¤:¨zÑ:Ô:‰JˆD�$Ø�OŠO˜DÑ!Ô!Ð!Øð Ø!��r‘
�
�
à˜2�J�J�Jð
 ð 	*Ø�OŠO˜FŸJšJ™LœLÑ)Ô)Ð)Ð)Ð)ð	*ð 	*r   c                 ó`  — g }| j         dk    rt          d| j         z  ¦  «        ‚| j        �t| j        dk    r| j        }n| j        }|                      |¦  «        |                      | j                             ¦   «         ¦  «        z   | j         k    rt          d¦  «        ‚|                     ¦   «          |�r÷g }d}|r| j        }n| j        }| j         t          |¦  «        z
  }| j
        r#|d                              ¦   «         dk    r|r|d= |rT|                      |d         ¦  «        }||z   |k    r-|                     |                     ¦   «         ¦  «         ||z  }nn|°T|rY|                      |d         ¦  «        |k    r:|                      ||||¦  «         t          t!          t          |¦  «        ¦  «        }| j
        r|r|d                              ¦   «         s|d= |�rÄ| j        �Wt          |¦  «        dz   | j        k     s<|r4| j
        r`t          |¦  «        dk    rM|d                              ¦   «         s3||k    r-|                     |d                     |¦  «        z   ¦  «         �n9|r¤|d                              ¦   «         rg||                      | j        ¦  «        z   |k    rF|                     | j        ¦  «         |                     |d                     |¦  «        z   ¦  «         nµ||                      |d         ¦  «        z  }|d= |°¤|ra|d                              ¦   «         }|                      |¦  «        |                      | j        ¦  «        z   | j         k    r|| j        z   |d<   n3|                     || j                             ¦   «         z   ¦  «         n|�°÷|S )Nr   zinvalid width %r (must be > 0)r   z#placeholder too large for max widthr?   r/   )r   r   r   Úsubsequent_indentÚinitial_indentr-   ÚplaceholderÚlstripÚreverser6   Údrop_whitespaceÚstriprA   r   rG   r+   ÚmapÚjoinÚrstrip)	r   r9   ÚlinesÚindentrB   rC   r   ÚlÚ	prev_lines	            r   Ú_wrap_chunkszUTextWrapper._wrap_chunksž   së  € ØˆØŒ:˜Š?ˆ?ÝÐ=ÀÄ
ÑJÑKÔKÐKØŒ>Ð%ØŒ~ Ò!Ð!ØÔ/��àÔ,�Ø�{Š{˜6Ñ"Ô" T§[¢[°Ô1A×1HÒ1HÑ1JÔ1JÑ%KÔ%KÑKÈdÌjÒXÐXÝ Ð!FÑGÔGÐGð 	�ŠÑÔÐàñ I	ð ˆHØˆGð ð -ØÔ/��àÔ,�ð ”J¥ V¡¤Ñ,ˆEð Ô#ð ¨¨r¬
×(8Ò(8Ñ(:Ô(:¸bÒ(@Ð(@ÀUÐ(@Ø˜2�Jàð à—K’K  r¤
Ñ+Ô+�ð ˜Q‘; %Ò'Ð'Ø—O’O F§J¢J¡L¤LÑ1Ô1Ð1Ø˜q‘L�G�Gð ð ð ð ð 2˜$Ÿ+š+ f¨R¤jÑ1Ô1°EÒ9Ð9Ø×&Ò& v¨x¸À%ÑHÔHÐHÝ�c¥# xÑ0Ô0Ñ1Ô1�ð Ô#ð !¨ð !¸À"¼×9KÒ9KÑ9MÔ9Mð !Ø˜R�Lð ñ Ø”NÐ*Ý˜‘J”J ‘N T¤^Ò3Ð3Øð 4àÔ,ð 4õ ˜‘[”[ AÒ%Ð%Ø œŸšÑ*Ô*ð &Ø07¸5Ò0@Ð0@ð —L’L ¨"¯'ª'°(Ñ*;Ô*;Ñ!;Ñ<Ô<Ð<Ñ<à"ð IØ$ RœL×.Ò.Ñ0Ô0ð "Ø '¨$¯+ª+°dÔ6FÑ*GÔ*GÑ GÈ5Ò PÐ PØ$ŸOšO¨DÔ,<Ñ=Ô=Ð=Ø!ŸLšL¨°"·'²'¸(Ñ2CÔ2CÑ)CÑDÔDÐDØ!Ø 4§;¢;¨x¸¬|Ñ#<Ô#<Ñ<˜Ø$ R˜Lð #ð Ið !ð &Ø(-¨b¬	×(8Ò(8Ñ(:Ô(:˜IØ $§¢¨IÑ 6Ô 6¸¿ºÀTÔEUÑ9VÔ9VÑ VØ$(¤Jò!/ð !/à,5¸Ô8HÑ,H  b¡	Ø %ØŸš V¨dÔ.>×.EÒ.EÑ.GÔ.GÑ%GÑHÔHÐHØðS ñ I	ðV ˆr   c                 ó²  — t           j                             | t          j        |¦  «        ¦  «        }g }|D ]Ÿ}d}t          |¦  «        D ][\  }}|                      |¦  «        dk    r=||k     r|                     |||…         ¦  «         |                     |¦  «         |dz   }Œ\|t          |¦  «        k     r|                     ||d …         ¦  «         Œ |S )Nr   r   r   )	r   r   Ú_splitr   Úsafe_unicoder0   r"   rA   r6   )r   Útextr9   Úcjk_split_chunksÚchunkÚprev_posr2   Úchars           r   rY   zUTextWrapper._splitû   sì   € ÝÔ%×,Ò,¨Tµ7Ô3GÈÑ3MÔ3MÑNÔNˆØÐØð 		:ð 		:ˆEØˆHÝ& uÑ-Ô-ð 'ð '‘	��TØ×+Ò+¨DÑ1Ô1°QÒ6Ð6Ø #’~�~Ø(×/Ò/°°h¸s°lÔ0CÑDÔDÐDØ$×+Ò+¨DÑ1Ô1Ð1Ø" Q™w�HøØ�#˜e™*œ*Ò$Ð$Ø ×'Ò'¨¨h¨i¨iÔ(8Ñ9Ô9Ð9øØÐr   c                 óf   — t           j                             | t          j        |¦  «        ¦  «        S r%   )r   r   r   r   rZ   )r   r[   s     r   r   zUTextWrapper.wrap
  s&   € åÔ#×(Ò(¨­wÔ/CÀDÑ/IÔ/IÑJÔJÐJr   r%   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r"   r-   r3   r=   rG   rW   rY   r   r&   r   r   r   r   "   s¶   € € € € € ðð ð.=ð =ð =ð =ð Ið Ið Ið,ð ,ð ,ðð ð ðð ð ð,*ð *ð *ð<[ð [ð [ðz ð  ð  ðKð Kð Kð Kð Kr   r   c                 óD   — t          dd|i|¤Ž                     | ¦  «        S )aÈ  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.
    r   r&   )r   r   ©r[   r   r   s      r   r   r     s+   € õ Ð.Ð.˜eÐ. vÐ.Ð.×3Ò3°DÑ9Ô9Ð9r   c                 óD   — t          dd|i|¤Ž                     | ¦  «        S )a–  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.
    r   r&   )r   r   rf   s      r   r   r     s+   € õ Ð.Ð.˜eÐ. vÐ.Ð.×3Ò3°DÑ9Ô9Ð9r   r%   )r   Úunicodedatar   r    r/   r   Ú__all__r   r   r   r   r&   r   r   ú<module>rj      s¯   ðð4 €€€Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4à Ð Ð Ð Ð Ð à
*Ð
*Ð
*€ðjKð jKð jKð jKð jK�8Ô'ñ jKô jKð jKð^
:ð 
:ð 
:ð 
:ð	:ð 	:ð 	:ð 	:ð 	:ð 	:r   