Xj(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 d/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/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. .. 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)initial_indentsubsequent_indentreplace_whitespaceNc sydjdk(r+jxsdddjddfn'jxsdddjfdd=y)NrT rF )stripappendjoin)bufindentpsr _flush_parzwrap_text.._flush_parNsg  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_textrHs7>' ?? D %+ G ||D!!%'AC F!  LF~#D>{{}!HTN2 JJt  L B.T  ! !#, / . '--d34 ',,t,-  . .. ;;r?  . .s AD))D2 ceZdZUdZded<ded<ded<ded< d dd Zdd Zdd Zdd Zddd Z ddZ ddZ ddZ d ddZ eddZed dZd!dZy)" 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. intindent_incrementrAcurrent_indentz list[str]bufferNc||_|d}|=ddl}t}|1tt |j j |dz d}||_d|_g|_ y)NPr2) rLshutilr rminget_terminal_sizecolumnsrArMrN)selfrLrA max_widthrSs r__init__zHelpFormatter.__init__sh !1  I =  E}C 8 8 : B BINQRRTVW  r c:|jj|y)z1Writes a unicode string into the internal buffer.N)rNr0)rWstrings rwritezHelpFormatter.writes 6"r cB|xj|jz c_y)zIncreases the indentation.NrMrLrWs rr3zHelpFormatter.indent t444r cB|xj|jzc_y)zDecreases the indentation.Nr^r_s rdedentzHelpFormatter.dedentr`r cl|djtd}|d|jd|d}|j|jz }|s2|j |j d|j dy|t |d zk\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: "``. Nz{usage} zUsage:)usage>r"r.r-)r(r)) format_rMrAr\rstriprrHr)rWprogargsprefix usage_prefix text_widthr3s r write_usagezHelpFormatter.write_usages) >&&Qx[&9F 4#6#6"7p 78a@ ZZ$"5"55  JJ|**3/ 0 JJt   (<025 68L11F JJ#/&,   JJ| $ JJt C 3 3Xf5EFJKF JJ*Vv  4r cN|jdd|jd|dy)z!Writes a heading into the buffer.r"rez: N)r\rM)rWheadings r write_headingzHelpFormatter.write_headings, b4../p/0 =>r c@|jr|jdyy)z#Writes a paragraph into the buffer.r-N)rNr\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)rMr\rHrA)rWr@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. rQz(Expected two columns for definition listrr"rer-r. T)rBrN) listrr# TypeErrorrTr%r\rMrrrArHr<) rWrcol_max col_spacingr first_colfirstsecondro 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")r1rNr_s rgetvaluezHelpFormatter.getvalue)swwt{{##r )rQNN)rLrKrAr rXr r7r8)r[strr7r8r6)r"N)rkrrlrrmz str | Noner7r8)rrrr7r8)r@rr7r8)rQ)rcabc.Iterable[tuple[str, str]]r|rKr}rKr7r8)rrr7cabc.Generator[None])r7r)r7r)__name__ __module__ __qualname____doc____annotations__rYr\r3rbrprsrurwrrrrrr r rrJrJns  J !" $    &#55,\? & *!,*!*! *!  *!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_slashoptrms r join_optionsr.sy B&C# S="&  3v;$% &GGG 99&2& &(; ;;r )rrr7ztuple[int, ...])rrr$rKr7zcabc.Iterator[tuple[str, ...]])Nr"r"F) r@rrArKr(rr)rrBboolr7r)rzcabc.Iterable[str]r7ztuple[str, bool]) __future__rcollections.abcabccabc contextlibrrri_compatrparserrr rrr%rHrJrr r rrs"%  j73 (3583#3 % L L LL L  L  L^}$}$@