Dd% UddlZddlmZddlmZddlmZddlm Z dZ eje e d<dejejeefd eje d ffd Zdejejeefd e d ej$ejed ffd Z ddede dededed ef dZGddZdej.ed ejeeffdZy)N)contextmanager)gettext)term_len) split_opt FORCED_WIDTHrowsreturn.ci}|D]=}t|D]-\}}t|j|dt|||</?t dt |j DS)Nrc3&K|] \}}| yw)N).0xys 2/usr/lib/python3/dist-packages/click/formatting.py z measure_table..s6tq!6) enumeratemaxgetrtuplesorteditems)r widthsrowidxcols r measure_tabler sn!FA!# AHCfjja0(3-@F3K AA 6vflln56 66 col_countc#FK|D]}|d|t|z zzyw)N))len)r r rs r iter_rowsr$s03EYS12223s!textwidthinitial_indentsubsequent_indentpreserve_paragraphscj ddlm}|j}||||d}|s|j|Sgg d d fd }|j D]J}|s |d  )t |} |j }| t |z j|L|g} D]f\ } }|jd z5| r!| j|j|n | j|j|dddhdj| S#1swYxYw) aA helper function that intelligently wraps text. By default, it assumes that it operates on a single paragraph of text but if the `preserve_paragraphs` parameter is provided it will intelligently handle paragraphs (defined by two empty lines). If paragraphs are handled, a paragraph can be prefixed with an empty line containing the ``\b`` character (``\x08``) to indicate that no rewrapping should happen in that block. :param text: the text that should be rewrapped. :param width: the maximum width for the text. :param initial_indent: the initial indent that should be placed on the first line as a string. :param subsequent_indent: the indent string that should be placed on each consecutive line. :param preserve_paragraphs: if this flag is set then the wrapping will intelligently handle paragraphs. r) TextWrapperF)r'r(replace_whitespaceNc sydjdk(r+jxsdddjddfn'jxsdddjfdd=y)NrT rF )stripappendjoin)bufindentpsr _flush_parzwrap_text.._flush_parFsg  q6<<>T ! HHfk43qr7);< = HHfk5#((3-8 9 Frr0z r N) _textwrapr+ expandtabsfill splitlinesrlstripr2 extra_indent indent_onlyr3)r%r&r'r(r)r+wrapperr7lineorig_lenrvrawr4r5r6s @@@r wrap_textrEs72' ?? D %+ G ||D!!)+AC F!  LF~#D>{{}!HTN2 JJt  L B.T  ! !#, / . '--d34 ',,t,-  . .. ;;r?  . .s AD))D2 c eZdZdZ ddedej edej eddfdZdeddfd Z dd Z dd Z dd ed edej eddfdZ deddfdZ ddZdeddfdZ d dej ej"eefdededdfdZededej(dfdZedej(dfdZdefdZy)! HelpFormatteraThis class helps with formatting text-based help pages. It's usually just needed for very special internal cases, but it's also exposed so that developers can write their own fancy outputs. At present, it always writes into memory. :param indent_increment: the additional increment for each level. :param width: the width for the text. This defaults to the terminal width clamped to a maximum of 78. Nindent_incrementr& max_widthr cddl}||_|d}|9t}|1tt |j j |dz d}||_d|_g|_ y)NrP2) shutilrHrrminget_terminal_sizecolumnsr&current_indentbuffer)selfrHr&rIrNs r__init__zHelpFormatter.__init__rsh  0  I = E}C 8 8 : B BINQRRTVW #% rstringc:|jj|y)z1Writes a unicode string into the internal buffer.N)rSr2)rTrVs rwritezHelpFormatter.writes 6"rcB|xj|jz c_y)zIncreases the indentation.NrRrHrTs rr5zHelpFormatter.indent t444rcB|xj|jzc_y)zDecreases the indentation.NrZr[s rdedentzHelpFormatter.dedentr\rprogargsprefixc|tdd}|d|jd|d}|j|jz }|t|dzk\r-dt|z}|j t ||||ne|j ||j ddt |jt|d zz}|j t |||||j dy) zWrites a usage line into the buffer. :param prog: the program name. :param args: whitespace separated list of arguments. :param prefix: The prefix for the first line. Defaults to ``"Usage: "``. NzUsage:r0>r")r'r(r/)_rRr&rrXrEr)rTr_r`ra usage_prefix text_widthr5s r write_usagezHelpFormatter.write_usages >( }A&F 4#6#6"7p 78a@ ZZ$"5"55 (<025 68L11F JJ#/&,   JJ| $ JJt C 3 3Xf5EFJKF JJ*Vv  4rheadingcN|jdd|jd|dy)z!Writes a heading into the buffer.r"rcz: N)rXrR)rTrjs r write_headingzHelpFormatter.write_headings, b4../p/0 =>rc@|jr|jdyy)z#Writes a paragraph into the buffer.r/N)rSrXr[s rwrite_paragraphzHelpFormatter.write_paragraphs ;; JJt  rr%c d|jz}|jt||j||d|jdy)zaWrites re-indented text into the buffer. This rewraps and preserves paragraphs. r0T)r'r(r)r/N)rRrXrEr&)rTr%r5s r write_textzHelpFormatter.write_textsIt***  %"($(    4rr col_max col_spacingc,t|}t|}t|dk7r tdt |d||z}t |t|D]:\}}|j dd|jd||s|j d?t|||z kr!|j d|t|z zn2|j d|j d||jzzt|j|z dz d}t||d } | j} | rK|j | dd| d d D]*} |j dd||jzd| d,*|j d=y ) anWrites a definition list into the buffer. This is how options and commands are usually formatted. :param rows: a list of two item tuples for the terms and values. :param col_max: the maximum width of the first column. :param col_spacing: the number of spaces between the first and second column. rLz(Expected two columns for definition listrr"rcr/r0 T)r)rN) listrr# TypeErrorrOr$rXrRrrr&rEr<) rTr rqrrr first_colfirstsecondrh wrapped_textlinesrAs rwrite_dlzHelpFormatter.write_dlsDzt$ v;! FG Gq 7+k9 &tS[9 !ME6 JJ"Qt223034UG< = 4 )k"99 3)huo"=>? 4  3)d.A.A"ABCTZZ)3a7)>;>c8dj|jS)zReturns the buffer contents.r")r3rSr[s rgetvaluezHelpFormatter.getvalueswwt{{##r)rLNNr8)r"N)rL)__name__ __module__ __qualname____doc__inttOptionalrUstrrXr5r^rirlrnrpSequenceTupler|rIteratorrrrr rrrGrGfso !"!%%) &&zz#&::c? &  &&#C#D#55 DH&&"&12C& &P?S?T? st& *!jjc*+*!*! *!  *!X C AJJt$4  QZZ-$#$rrGoptionscg}d}|D]3}t|d}|dk(rd}|jt||f5|jddj d|D|fS) a Given a list of option strings this joins them in the most appropriate way and returns them in the form ``(formatted_string, any_prefix_is_slash)`` where the second item in the tuple is a flag that indicates if any of the option prefixes was a slash. Fr/Tc |dS)Nrr )rs rzjoin_options..,s !A$r)keyz, c3&K|] }|d yw)rNr )rrs rrzjoin_options..-s&aQqT&r)rr2r#sortr3)rrCany_prefix_is_slashoptras r join_optionsrsy B&3" S="&  3v;$% &GGG 99&2& &(; ;;r)Nr"r"F)typingr contextlibrrrf_compatrparserrrrr__annotations__Iterablerrrrr$boolrErGrrr rrrs/% !% ajjo$7 17738#457!''#s(:K73 **QWWS#X& '3473ZZS!"3 % F F FF F  F  FRr$r$j