L i&UddlmZddlmZddlmZddlmZddl m Z ddl m Z dZ ded <dd Z dd Z d dd ZGd dZddZy)) annotationsN)contextmanager)gettext)term_len) _split_opt int | None FORCED_WIDTHci}|D]=}t|D]-\}}t|j|dt|||</?t dt |j DS)Nrc3&K|] \}}| yw)N).0xys V/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/click/formatting.py z measure_table..s6tq!6) enumeratemaxgetrtuplesorteditems)rowswidthsrowidxcols r measure_tablersnFA!# AHCfjja0(3-@F3K AA 6vflln56 66c#FK|D]}|d|t|z zzyw)N))len)r col_countrs r iter_rowsr%s03EYS12223s!cj 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)initial_indentsubsequent_indentreplace_whitespaceNc sydjdk(r+jxsdddjddfn'jxsdddjfdd=y)NrT rF )stripappendjoin)bufindentpsr _flush_parzwrap_text.._flush_parHsg  q6<<>T ! HHfk43qr7);< = HHfk5#((3-8 9 Fr r.z returnNone) _textwrapr' expandtabsfill splitlinesrlstripr0 extra_indent indent_onlyr1)textwidthr(r)preserve_paragraphsr'wrapperr5lineorig_lenrvrawr2r3r4s @@@r wrap_textrHs72' ?? D %+ G ||D!!%'AC F!  LF~#D>{{}!HTN2 JJt  L B.T  ! !#, / . '--d34 ',,t,-  . .. ;;r?  . .s AD))D2 ceZdZdZ d ddZddZddZddZdddZddZ dd Z dd Z d dd Z e dd Ze dd ZddZy) 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. Nc||_|d}|=ddl}t}|1tt |j j |dz d}||_d|_g|_ y)NPr2) indent_incrementshutilr rminget_terminal_sizecolumnsrAcurrent_indentbuffer)selfrOrA max_widthrPs r__init__zHelpFormatter.__init__tsh !1  I =  E}C 8 8 : B BINQRRTVW #$!# r c:|jj|y)z1Writes a unicode string into the internal buffer.N)rUr0)rVstrings rwritezHelpFormatter.writes 6"r cB|xj|jz c_y)zIncreases the indentation.NrTrOrVs rr3zHelpFormatter.indent t444r cB|xj|jzc_y)zDecreases the indentation.Nr]r^s rdedentzHelpFormatter.dedentr_r c|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:r.>r")r(r)r-)_rTrArr[rHr)rVprogargsprefix usage_prefix text_widthr3s 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  4r cN|jdd|jd|dy)z!Writes a heading into the buffer.r"rcz: N)r[rT)rVheadings r write_headingzHelpFormatter.write_headings, b4../p/0 =>r c@|jr|jdyy)z#Writes a paragraph into the buffer.r-N)rUr[r^s rwrite_paragraphzHelpFormatter.write_paragraphs ;; JJt  r c d|jz}|jt||j||d|jdy)zaWrites re-indented text into the buffer. This rewraps and preserves paragraphs. r.T)r(r)rBr-N)rTr[rHrA)rVr@r3s r write_textzHelpFormatter.write_textsIt***  %"($(    4r c,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. rMz(Expected two columns for definition listrr"rcr-r. T)rBrN) listrr# TypeErrorrQr%r[rTrrrArHr<) rVrcol_max col_spacingr first_colfirstsecondrk wrapped_textlinesrDs 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")r1rUr^s rgetvaluezHelpFormatter.getvalueswwt{{##r )rMNN)rOintrAr rWr r7r8)rZstrr7r8r6)r"N)rgrrhrriz str | Noner7r8)rnrr7r8)r@rr7r8)rM)rzcabc.Sequence[tuple[str, str]]rxrryrr7r8)rrr7cabc.Iterator[None])r7r)r7r)__name__ __module__ __qualname____doc__rXr[r3rarlrorqrsrrrrrr r rrJrJhs !" $ $$$ $  $&#55$L? & *!,*!*! *!  *!X  $r rJcg}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)rr0r#sortr1)optionsrFany_prefix_is_slashoptris r join_optionsrsy B&C# S="&  3v;$% &GGG 99&2& &(; ;;r )rcabc.Iterable[tuple[str, str]]r7ztuple[int, ...])rrr$rr7zcabc.Iterator[tuple[str, ...]])Nr"r"F) r@rrArr(rr)rrBboolr7r)rzcabc.Sequence[str]r7ztuple[str, bool]) __future__rcollections.abcabccabc contextlibrrrf_compatrparserrr __annotations__rr%rHrJrr r rrs"%  j73 (3583#3 % F F FF F  F  FRp$p$f