zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
U
ß=®dê%ã@sôUddlZddlmZddlmZddlmZddlm    Z    dZ
ej e e d<ejejeefeje dfd    œd
d „Zejejeefe ejejedfd œd d„Zdee eeeedœdd„ZGdd„dƒZejeejeefdœdd„ZdS)éN)Úcontextmanager)Úgettexté)Úterm_len)Ú    split_optÚ FORCED_WIDTH.)ÚrowsÚreturncCsTi}|D]0}t|ƒD]"\}}t| |d¡t|ƒƒ||<qqtdd„t| ¡ƒDƒƒS)Nrcss|]\}}|VqdS)N©)Ú.0ÚxÚyr
r
úGd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\click/formatting.pyÚ    <genexpr>sz measure_table.<locals>.<genexpr>)Ú    enumerateÚmaxÚgetrÚtupleÚsortedÚitems)rÚwidthsÚrowÚidxÚcolr
r
rÚ measure_table s
r)rÚ    col_countr    ccs$|D]}|d|t|ƒVqdS)N)Ú)Úlen)rrrr
r
rÚ    iter_rowssréNrF)ÚtextÚwidthÚinitial_indentÚsubsequent_indentÚpreserve_paragraphsr    c
sddlm}| ¡}||||dd}|s2| |¡Sg‰g‰d‰ddœ‡‡‡fdd„ }| ¡D]B}|sp|ƒd‰q\ˆdkr”t|ƒ}    | ¡}|    t|ƒ‰ˆ |¡q\|ƒg}
ˆD]J\‰} }| d    ˆ¡,| rÞ|
 |     |¡¡n|
 | |¡¡W5QRXq®d
 
|
¡S) a²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.
    r)Ú TextWrapperF)r"r#Úreplace_whitespaceN©r    c    sdˆsdSˆd ¡dkr<ˆ ˆp"ddd ˆdd…¡f¡nˆ ˆpFddd ˆ¡f¡ˆdd…=dS)NrúTÚ
rFú )ÚstripÚappendÚjoinr
©ÚbufÚindentÚpr
rÚ
_flush_parFs $zwrap_text.<locals>._flush_parr*z
 
) Z    _textwrapr%Ú
expandtabsÚfillÚ
splitlinesrÚlstripr,Z extra_indentZ indent_onlyr-) r r!r"r#r$r%Úwrapperr2ÚlineZorig_lenÚrvÚrawr
r.rÚ    wrap_texts> ü
       r;c@seZdZdZd&eejeejeddœdd„Zeddœdd    „Z    dd
œd d „Z
dd
œd d„Z d'eeejeddœdd„Z eddœdd„Z dd
œdd„Zeddœdd„Zd(ejejeefeeddœdd„Zeeejddœd d!„ƒZeejdd
œd"d#„ƒZed
œd$d%„ZdS))Ú HelpFormattera¾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.
    éN)Úindent_incrementr!Ú    max_widthr    cCs^ddl}||_|dkrd}|dkrHt}|dkrHtt| ¡j|ƒddƒ}||_d|_g|_    dS)NréPr=é2)
Úshutilr>rrÚminÚget_terminal_sizeÚcolumnsr!Úcurrent_indentÚbuffer)Úselfr>r!r?rBr
r
rÚ__init__rszHelpFormatter.__init__)Ústringr    cCs|j |¡dS)z1Writes a unicode string into the internal buffer.N)rGr,)rHrJr
r
rÚwrite…szHelpFormatter.writer'cCs|j|j7_dS)zIncreases the indentation.N©rFr>©rHr
r
rr0‰szHelpFormatter.indentcCs|j|j8_dS)zDecreases the indentation.NrLrMr
r
rÚdedentszHelpFormatter.dedentr)ÚprogÚargsÚprefixr    cCs¾|dkrtdƒ›d}|d|j››|›d}|j|j}|t|ƒdkrndt|ƒ}| t||||d¡nB| |¡| d¡dt|jt|ƒƒd}| t||||d¡| d¡dS)    zï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. Defaults to
            ``"Usage: "``.
        NzUsage:r*ú>é)r"r#r)é)Ú_rFr!rrKr;r)rHrOrPrQZ usage_prefixÚ
text_widthr0r
r
rÚ write_usage‘s4
  üÿ
 
 
ÿÿzHelpFormatter.write_usage)Úheadingr    cCs"| dd|j››|›d¡dS)z!Writes a heading into the buffer.rrRz:
N)rKrF)rHrXr
r
rÚ write_heading¹szHelpFormatter.write_headingcCs|jr| d¡dS)z#Writes a paragraph into the buffer.r)N)rGrKrMr
r
rÚwrite_paragraph½szHelpFormatter.write_paragraph)r r    c    Cs2d|j}| t||j||dd¡| d¡dS)zaWrites re-indented text into the buffer.  This rewraps and
        preserves paragraphs.
        r*T)r"r#r$r)N)rFrKr;r!)rHr r0r
r
rÚ
write_textÂs
ûÿ    zHelpFormatter.write_texté)rÚcol_maxÚ col_spacingr    c CsLt|ƒ}t|ƒ}t|ƒdkr$tdƒ‚t|d|ƒ|}t|t|ƒƒD]\}}| dd|j››|›¡|sz| d¡qDt|ƒ||kr¢| d|t|ƒ¡n| d¡| d||j¡t    |j
|ddƒ}t ||d    d
}    |      ¡}
|
r<| |
d›d¡|
d d …D](} | dd||j››| ›d¡qqD| d¡qDd 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.
        r=z(Expected two columns for definition listrrrRr)r*é
T)r$rN) ÚlistrrÚ    TypeErrorrCrrKrFrrr!r;r5) rHrr]r^rZ    first_colÚfirstÚsecondrVZ wrapped_textÚlinesr8r
r
rÚwrite_dlÒs, 
 
(zHelpFormatter.write_dl)Únamer    ccs4| ¡| |¡| ¡z
dVW5| ¡XdS)z Helpful context manager that writes a paragraph, a heading,
        and the indents.
 
        :param name: the section name that is written as heading.
        N)rZrYr0rN)rHrfr
r
rÚsectionþs 
 
zHelpFormatter.sectionccs"| ¡z
dVW5| ¡XdS)z1A context manager that increases the indentation.N)r0rNrMr
r
rÚ indentation s
zHelpFormatter.indentationcCs d |j¡S)zReturns the buffer contents.r)r-rGrMr
r
rÚgetvalueszHelpFormatter.getvalue)r=NN)rN)r\r=)Ú__name__Ú
__module__Ú __qualname__Ú__doc__ÚintÚtÚOptionalrIÚstrrKr0rNrWrYrZr[ÚSequenceÚTuplererÚIteratorrgrhrir
r
r
rr<fsJ üû ÿþ (üû ,r<)Úoptionsr    cCsdg}d}|D].}t|ƒd}|dkr(d}| t|ƒ|f¡q |jdd„dd d    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ú/TcSs|dS)Nrr
)r r
r
rÚ<lambda>,ózjoin_options.<locals>.<lambda>)Úkeyz, css|]}|dVqdS)rNr
)r r r
r
rr-szjoin_options.<locals>.<genexpr>)rr,rÚsortr-)rur9Zany_prefix_is_slashÚoptrQr
r
rÚ join_optionss r|)rrrF)ÚtypingroÚ
contextlibrrrUÚ_compatrÚparserrrrprnÚ__annotations__ÚIterablersrqrrtrÚboolr;r<rrr|r
r
r
rÚ<module>s4    * þ     ûú I6