4V=j(UddlmZddlmZddlmZddlmZddl m Z ddl m Z dZ ded <d$dZd%dZ d&d'dZGddZd(d#ZdS))) annotationsN)contextmanager)gettext)term_len) _split_opt int | None FORCED_WIDTHrowscabc.Iterable[tuple[str, str]]returntuple[int, ...]ci}|D]K}t|D]9\}}t||dt|||<:Lt dt |DS)Nrc3 K|] \}}|V dS)N).0xys >C:\PYTHON\_runtimes\venv\Lib\site-packages\click/formatting.py z measure_table..s&66tq!666666) enumeratemaxgetrtuplesorteditems)r widthsrowidxcols r measure_tabler"sFAA!# A AHCfjja00(3--@@F3KK A 66vfllnn55666 6 66r col_countintcabc.Iterator[tuple[str, ...]]c#HK|D]}|d|t|z zzVdS)N))len)r r#rs r iter_rowsr)sE33EYS122222233rNr'Ftextstrwidthinitial_indentsubsequent_indentpreserve_paragraphsboolc ddlm}|}||||d}|s||Sgg d d fd }|D]]}|s |d  5t |} |}| t |z |^|g} D]\ } }|d z5| r)| | |n(| ||dddn #1swxYwYd | S) 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. .. versionchanged:: 8.4.0 Width is measured in visible characters. ANSI escape sequences in ``text``, ``initial_indent``, or ``subsequent_indent`` no longer count toward the width budget, so styled input wraps based on what the user sees instead of raw byte length. r) TextWrapperF)r.r/replace_whitespaceNr Nonec sdSddkr6pdddddfn-pdddfdd=dS)NrT rF )stripappendjoin)bufindentpsr _flush_parzwrap_text.._flush_parNs  F q6<<>>T ! ! HHfk43qrr7););< = = = = HHfk5#((3--8 9 9 9 FFFrr9z r r5) _textwrapr3 expandtabsfill splitlinesrlstripr; extra_indent indent_onlyr<)r+r-r.r/r0r3wrapperr@lineorig_lenrvrawr=r>r?s @@@r wrap_textrNs>'&&&&& ??  Dk %+ G "||D!!!%'AC F!!    JLLLFF~#D>>{{}}!HTNN2 JJt    JLLL B..T  ! !#, / / . . . '--d334444 ',,t,,---  . . . . . . . . . . . . . . . ;;r??s0AEE E ceZdZUdZded<ded<ded<ded< d*d+dZd,dZd-dZd-dZd.d/dZ d0dZ d-dZ d1dZ d2d3d$Z ed4d'Zed5d(Zd6d)Zd S)7 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. r$indent_incrementr-current_indentz list[str]bufferNr max_widthr r5c||_|d}|Eddl}t}|8tt |j|dz d}||_d|_g|_ dS)NPrrT2) rQshutilr rminget_terminal_sizecolumnsr-rRrS)selfrQr-rUrYs r__init__zHelpFormatter.__init__sx !1  I = MMM E}C 8 8 : : BINNQRRTVWW  rstringr,c:|j|dS)z1Writes a unicode string into the internal buffer.N)rSr;)r]r_s rwritezHelpFormatter.writes 6"""""rc0|xj|jz c_dS)zIncreases the indentation.NrRrQr]s rr>zHelpFormatter.indent t44rc0|xj|jzc_dS)zDecreases the indentation.Nrcrds rdedentzHelpFormatter.dedentrerr'progargsprefix str | Nonec|#dtd}|d|j|d}|j|jz }|s?||d|ddS|t |dzkr9dt |z}|t|||| nx|||ddt|jt |d zz}|t|||| |ddS) 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: "``. Nz{usage} zUsage:)usage>r9r8)r.r/) format_rRr-rarstriprrNr)r]rhrirj usage_prefix text_widthr>s r write_usagezHelpFormatter.write_usages >&&Qx[[&99F @4#6@@@@@@ Z$"55   JJ|**3// 0 0 0 JJt    F (<0025 6 68L111F JJ#/&,      JJ| $ $ $ JJt   C 3Xf5E5EFFJKF JJ*Vv    4rheadingcL|dd|j|ddS)z!Writes a heading into the buffer.r'rnz: N)rarR)r]rws r write_headingzHelpFormatter.write_headings6 b=4.======>>>>>rcB|jr|ddSdS)z#Writes a paragraph into the buffer.r8N)rSrards rwrite_paragraphzHelpFormatter.write_paragraphs. ;  JJt       rr+c d|jz}|t||j||d|ddS)zaWrites re-indented text into the buffer. This rewraps and preserves paragraphs. r9T)r.r/r0r8N)rRrarNr-)r]r+r>s r write_textzHelpFormatter.write_textsdt**  %"($(        4rr r col_max col_spacingct|}t|}t|dkrtdt |d||z}t |t|D]_\}}|dd|j||s|d@t|||z kr)|d|t|z zn5|d|d||jzzt|j |z dz d}t||d } | } | rS|| dd| d d D](} |dd||jz| d)J|dad S) 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. rTz(Expected two columns for definition listrr'rnr8r9 T)r0rN) listr"r( TypeErrorrZr)rarRrrr-rNrE) r]r rrr first_colfirstsecondru wrapped_textlinesrJs rwrite_dlzHelpFormatter.write_dlsDzzt$$ v;;!  FGG Gq 7++k9 &tS[[99 ! !ME6 JJ"???? 4    3)d.A"ABCCCTZ)3a7<rg)r]rs rsectionzHelpFormatter.sectionsl  4      EEE KKMMMMMDKKMMMMs AA1c#K| dV|dS#|wxYw)z1A context manager that increases the indentation.N)r>rgrds r indentationzHelpFormatter.indentation sF   EEE KKMMMMMDKKMMMMs 2Ac6d|jS)zReturns the buffer contents.r')r<rSrds rgetvaluezHelpFormatter.getvalue)swwt{###r)rTNN)rQr$r-r rUr r r5)r_r,r r5rA)r'N)rhr,rir,rjrkr r5)rwr,r r5)r+r,r r5)r~rT)r r rr$rr$r r5)rr,r r)r r)r r,)__name__ __module__ __qualname____doc____annotations__r^rar>rgrvryr{r}rrrrrrrrrPrPns{  JJJ!" $ &####55555555,,,,,\???? & *!*!*!*!*!X   ^ ^$$$$$$rrPoptionscabc.Iterable[str]tuple[str, bool]cg}d}|D]C}t|d}|dkrd}|t||fD|ddd|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|] }|dV dS)rNr)rrs rrzjoin_options..@s&&&aQqT&&&&&&r)rr;r(sortr<)rrLany_prefix_is_slashoptrjs r join_optionsr.s B&&C# S=="&  3v;;$%%%%GGG 99&&2&&& & &(; ;;r)r r r r)r r r#r$r r%)r*r'r'F) r+r,r-r$r.r,r/r,r0r1r r,)rrr r) __future__rcollections.abcabccabc contextlibrrrr_compatrparserrr rr"r)rNrPrrrrrs+"""""""%%%%%%  77773333 % LLLLL^}$}$}$}$}$}$}$}$@<<<<<