ó œÃÒYc@sddlmZddlmZddlmZddlmZdZ d„Z d„Z dd d e d „Z d efd „ƒYZd „ZdS(iÿÿÿÿ(tcontextmanageri(tget_terminal_size(t split_opt(tterm_lencCsyi}xP|D]H}x?t|ƒD]1\}}t|j|dƒt|ƒƒ||s(t enumeratetmaxtgetRttupletsortedtitems(trowstwidthstrowtidxtcol((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyt measure_table s  -ccs8x1|D])}t|ƒ}|d|t|ƒVqWdS(Nt(R(R tlen(R t col_countR((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyt iter_rowss  iNRc shddlm}|jƒ}||d|d|dtƒ}|sM|j|ƒSg‰g‰d‰‡‡‡fd†}xn|jƒD]`}|s|ƒd‰qˆdkrÔt|ƒ} |jƒ}| t|ƒ‰nˆj |ƒqW|ƒg} xfˆD]^\‰} }|j dˆƒ:| r;| j |j |ƒƒn| j |j|ƒƒWdQXqùWd j | ƒS( s²A 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. i(t TextWrappertinitial_indenttsubsequent_indenttreplace_whitespacecsyˆs dSˆdjƒdkrLˆjˆp/dtdjˆdƒfƒn%ˆjˆp[dtdjˆƒfƒˆ2dS(Niss it (tstriptappendtTruetjointFalse((tbuftindenttp(sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyt _flush_par9s ,%RNs ( t _textwrapRt expandtabsR tfilltNonet splitlinesRtlstripRt extra_indentt indent_onlyR( ttexttwidthRRtpreserve_paragraphsRtwrapperR$tlinetorig_lentrvtraw((R!R"R#sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyt wrap_texts8         t HelpFormattercBs›eZdZdddd„Zd„Zd„Zd„Zddd„Zd „Z d „Z d „Z d dd „Z e d„ƒZe d„ƒZd„ZRS(s¾This 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. icCs„||_|dkrd}n|dkret}|dkretttƒd|ƒddƒ}qen||_d|_g|_dS(NiPiii2( tindent_incrementR(t FORCED_WIDTHRtminRR.tcurrent_indenttbuffer(tselfR7R.t max_width((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyt__init__es     )  cCs|jj|ƒdS(s1Writes a unicode string into the internal buffer.N(R;R(R<tstring((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pytwriteqscCs|j|j7_dS(sIncreases the indentation.N(R:R7(R<((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyR"uscCs|j|j8_dS(sDecreases the indentation.N(R:R7(R<((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pytdedentysRsUsage: cCsÞd|j||f}|j|j}|t|ƒdkrqdt|ƒ}|jt||d|d|ƒƒn\|j|ƒ|jdƒdt|jt|ƒƒd}|jt||d|d|ƒƒ|jdƒdS( sÈWrites 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. s%*s%s iRRRs iN(R:R.RR@R5R(R<tprogtargstprefixt usage_prefixt text_widthR"((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyt write_usage}s     cCs!|jd|jd|fƒdS(s!Writes a heading into the buffer.s%*s%s: RN(R@R:(R<theading((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyt write_heading˜scCs|jr|jdƒndS(s#Writes a paragraph into the buffer.s N(R;R@(R<((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pytwrite_paragraphœs c Cs_t|j|jdƒ}d|j}|jt||d|d|dtƒƒ|jdƒdS(saWrites re-indented text into the buffer. This rewraps and preserves paragraphs. i RRRR/s N(RR.R:R@R5R(R<R-RFR"((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyt write_text¡s  ic Cst|ƒ}t|ƒ}t|ƒdkr9tdƒ‚nt|d|ƒ|}xFt|t|ƒƒD]/\}}|jd|jd|fƒ|s¨|jdƒqfnt|ƒ||krÜ|jd|t|ƒƒn%|jdƒ|jd||jƒt |j |ddƒ}t t ||ƒj ƒƒ} | rˆ|jt| ƒdƒx?| D]'} |jd ||jd| fƒqZWqf|jdƒqfWd S( snWrites 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. is(Expected two columns for definition listis%*s%sRs Ri s%*s%s N(tlistRRt TypeErrorR9RR@R:RRR.titerR5R)tnext( R<R tcol_maxt col_spacingRt first_coltfirsttsecondRFtlinesR1((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pytwrite_dl­s,  "    ccs<|jƒ|j|ƒ|jƒz dVWd|jƒXdS(s Helpful context manager that writes a paragraph, a heading, and the indents. :param name: the section name that is written as heading. N(RJRIR"RA(R<tname((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pytsectionÒs     ccs%|jƒz dVWd|jƒXdS(s1A context manager that increases the indentation.N(R"RA(R<((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyt indentationás  cCsdj|jƒS(sReturns the buffer contents.R(RR;(R<((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pytgetvalueêsN(t__name__t __module__t__doc__R(R>R@R"RARGRIRJRKRVRRXRYRZ(((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyR6Ys       % cCs‘g}t}xL|D]D}t|ƒd}|dkr>t}n|jt|ƒ|fƒqW|jdd„ƒdjd„|Dƒƒ}||fS(s 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. it/tkeycSs|dS(Ni((R((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pytýss, css|]}|dVqdS(iN((RR((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pys ÿs(R RRRRtsortR(toptionsR3tany_prefix_is_slashtoptRD((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyt join_optionsïs   N(t contextlibRttermuiRtparserRt_compatRR(R8RRR R5tobjectR6Re(((sc/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/formatting.pyts    ?–