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
148
149
150
151
152
153
U
¬ý°dY3ã@s„dZddlmZddlZddlmZmZmZmZddl    Z    ddl
m Z ddl m Z ddd    œd
d „Zdddd œdd„ZGdd„dƒZdS)zN
Utilities for interpreting CSS from Stylers for formatting non-HTML outputs.
é)Ú annotationsN)ÚCallableÚ    GeneratorÚIterableÚIterator)Ú
CSSWarning)Úfind_stack_levelÚstrr)Úprop_fmtÚreturncsdddœ‡fdd„ }|S)a)
    Wrapper to expand shorthand property into top, right, bottom, left properties
 
    Parameters
    ----------
    side : str
        The border side to expand into properties
 
    Returns
    -------
        function: Return to call when a 'border(-{side}): {value}' string is encountered
    r    ú&Generator[tuple[str, str], None, None]©Úvaluer c    3s€| ¡}z|jt|ƒ}Wn6tk
rPtjd|›d|›dttƒdYdSXt|j    |ƒD]\}}ˆ 
|¡||fVq^dS)a<
        Expand shorthand property into side-specific property (top, right, bottom, left)
 
        Parameters
        ----------
            prop (str): CSS property name
            value (str): String token for property
 
        Yields
        ------
            Tuple (str, str): Expanded property, value
        zCould not expand "z: ú"©Ú
stacklevelN) ÚsplitÚSIDE_SHORTHANDSÚlenÚKeyErrorÚwarningsÚwarnrrÚzipÚSIDESÚformat)ÚselfÚproprÚtokensÚmappingÚkeyÚidx©r
©úLd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/io/formats/css.pyÚexpand!s ýz_side_expander.<locals>.expandr")r
r$r"r!r#Ú_side_expandersr%Ú)Úsider cs*ˆdkrdˆ›‰dddœ‡fdd„ }|S)a.
    Wrapper to expand 'border' property into border color, style, and width properties
 
    Parameters
    ----------
    side : str
        The border side to expand into properties
 
    Returns
    -------
        function: Return to call when a 'border(-{side}): {value}' string is encountered
    r&ú-r    r r c3sÞ| ¡}t|ƒdks t|ƒdkr:tjd|›dttƒddˆ›dddˆ›d    d
dˆ›d d i}|D]^‰ˆ ¡|jkrŠˆ|dˆ›d    <qft‡fd d„|j    Dƒƒr´ˆ|dˆ›d <qfˆ|dˆ›d<qf| 
|  ¡¡EdHdS)aV
        Expand border into color, style, and width tuples
 
        Parameters
        ----------
            prop : str
                CSS property name passed to styler
            value : str
                Value passed to styler for property
 
        Yields
        ------
            Tuple (str, str): Expanded property, value
        rézToo many tokens provided to "z" (expected 1-3)rÚborderz-colorZblackz-styleÚnoneú-widthÚmediumc3s|]}|ˆ ¡kVqdS©N)Úlower)Ú.0Zratio©Útokenr"r#Ú    <genexpr>nsz3_border_expander.<locals>.expand.<locals>.<genexpr>N) rrrrrrr/Ú BORDER_STYLESÚanyÚBORDER_WIDTH_RATIOSÚatomizeÚitems)rrrrZborder_declarations©r'r1r#r$Ns*
ý
 
 
ýz _border_expander.<locals>.expandr")r'r$r"r9r#Ú_border_expander>s 
)r:c@s¢eZdZdZddddddddd    d
d d œ Ze ¡Ze d dddddddddddœ ¡e ¡Ze ddi¡e ¡Z    e     dddddœ¡dddd d!d"d#d$d%d&d'd(d)d*d+d,d-gZ
d.d.d.d.gd.d/d.d/gd.d/d0d/gd.d/d0d1gd2œZ d3Z d4d5„d6Dƒd7d5„d8Dƒe d9ƒe d:ƒd;œ–Zd^d=d>d?d@œdAdB„Zd?d?d?dCœdDdE„Zd?d?d?dCœdFdG„Zd?dHdIœdJdK„ZdLdMdNœdOdP„Zd?d?dIœdQdR„Zd<efdSdT„ZdUdVdWœdXdY„ZdLdZd[œd\d]„Zd<S)_Ú CSSResolverzH
    A callable for parsing and resolving CSS to atomic properties.
    )Úpté)Úemr=)r<é )r>çà?)r<gè?)r<éH)ÚingL&“Éd2Ù?)rBg
…B¡P(¤?)ÚmmgÐ?)r>r) r<r>ÚremÚexÚpxZpcrBÚcmrCÚqú    !!default)r>g{®Gáz„?)rDr@)rDgä?)rDgš™™™™™é?)rDr=)rDgò?)rDgø?)rDé)r>g«ªªªªªê?)r>g333333ó?) ú%zxx-smallzx-smallÚsmallr-Zlargezx-largezxx-largeZsmallerZlargerrIr+)r<r)rFé)rFrJ)rFr=)r+Zthickr-ZthinÚhiddenZdottedZdashedZsolidÚdoubleZgrooveZridgeZinsetZoutsetZ mediumdashdotZ
dashdotdotZhairZmediumdashdotdotZdashdotZ slantdashdotZ mediumdashedrr=rJr))r=rJr)rM)ÚtopÚrightÚbottomÚleftcCs$i|]}|rd|›ndt|ƒ“qS)úborder-r*)r:©r0rr"r"r#Ú
<dictcomp>ËsÿzCSSResolver.<dictcomp>)r&rPrQrRrScCs"i|]}d|›td|›ƒ“qS)rTz border-{:s}-)r%rUr"r"r#rVÏsÿ)ÚcolorÚstyleÚwidthz margin-{:s}z padding-{:s})ÚmarginÚpaddingNzstr | Iterable[tuple[str, str]]zdict[str, str] | Nonezdict[str, str])Ú declarationsÚ    inheritedr cCsPt|tƒr| |¡}t| |¡ƒ}|dkr.i}| ||¡}| ||¡}| |¡S)a£
        The given declarations to atomic properties.
 
        Parameters
        ----------
        declarations_str : str | Iterable[tuple[str, str]]
            A CSS string or set of CSS declaration tuples
            e.g. "font-weight: bold; background: blue" or
            {("font-weight", "bold"), ("background", "blue")}
        inherited : dict, optional
            Atomic properties indicating the inherited style context in which
            declarations_str is to be resolved. ``inherited`` should already
            be resolved, i.e. valid output of this method.
 
        Returns
        -------
        dict
            Atomic CSS 2.2 properties.
 
        Examples
        --------
        >>> resolve = CSSResolver()
        >>> inherited = {'font-family': 'serif', 'font-weight': 'bold'}
        >>> out = resolve('''
        ...               border-color: BLUE RED;
        ...               font-size: 1em;
        ...               font-size: 2em;
        ...               font-weight: normal;
        ...               font-weight: inherit;
        ...               ''', inherited)
        >>> sorted(out.items())  # doctest: +NORMALIZE_WHITESPACE
        [('border-bottom-color', 'blue'),
         ('border-left-color', 'red'),
         ('border-right-color', 'red'),
         ('border-top-color', 'blue'),
         ('font-family', 'serif'),
         ('font-size', '24pt'),
         ('font-weight', 'bold')]
        N)Ú
isinstancer    ÚparseÚdictr7Ú_update_initialÚ_update_font_sizeÚ_update_other_units)rr\r]Úpropsr"r"r#Ú__call__Ùs,
 
  zCSSResolver.__call__)rdr]r cCsl| ¡D]\}}||kr|||<q| ¡}| ¡D]4\}}|dkrN| |d¡}|dkr^||=q2|||<q2|S)NZinheritÚinitial)rfN)r8ÚcopyÚget)rrdr]rÚvalZ    new_propsr"r"r#ras
 
zCSSResolver._update_initialcCs.| d¡r*|j|d| |¡|jd|d<|S)Nú    font-size©Ú conversions)rhÚ
size_to_ptÚ_get_font_sizeÚFONT_SIZE_RATIOS)rrdr]r"r"r#rb%s
ý
zCSSResolver._update_font_sizez float | None)rdr cCs | d¡r|d}| |¡SdS)Nrj)rhÚ_get_float_font_size_from_pt)rrdÚfont_size_stringr"r"r#rn3s
 
zCSSResolver._get_font_sizer    Úfloat)rqr cCs| d¡st‚t| d¡ƒS)Nr<)ÚendswithÚAssertionErrorrrÚrstrip)rrqr"r"r#rp9sz(CSSResolver._get_float_font_size_from_ptcCs„| |¡}|jD]n}d|›d}||krB|j||||jd||<d|›d|›fD]&}||krV|j||||jd||<qVq|S)NrTr,)Úem_ptrlzmargin-zpadding-)rnrrmr6Ú MARGIN_RATIOS)rrdZ    font_sizer'rr"r"r#rc=s"
 
 ý
ýzCSSResolver._update_other_unitsc
s‡‡‡fdd„}t dˆ¡}|dkr*|ƒS| ¡\}}|dkrDd}n(z t|ƒ}Wntk
rj|ƒYSX|dkrÎ|dkr˜|dkrŠd}ql||9}d}qlzˆ|\}}Wntk
rÂ|ƒYSX||9}qlt|d    ƒ}t|ƒ|kröt|ƒd
›d}    n |d ›d}    |    S) Ncs*tjdtˆƒ›ttƒdˆjdˆdS)NzUnhandled size: rz
1!!defaultrk)rrÚreprrrrmr"©rlÚin_valrr"r#Ú_errorTs  ýz&CSSResolver.size_to_pt.<locals>._errorz^(\S*?)([a-zA-Z%!].*)r&r=r<r>rDéÚdÚf)ÚreÚmatchÚgroupsrrÚ
ValueErrorrÚroundÚint)
rrzrvrlr{r€riÚunitÚmulZsize_fmtr"ryr#rmSs8     
 
  zCSSResolver.size_to_ptrr )r\r ccsT|D]J\}}| ¡}| ¡}||jkrD|j|}||||ƒEdHq||fVqdSr.)r/ÚCSS_EXPANSIONS)rr\rrr$r"r"r#r7€s 
 
zCSSResolver.atomizezIterator[tuple[str, str]])Údeclarations_strr ccsr| d¡D]b}| ¡sq
| d¡\}}}| ¡ ¡}| ¡ ¡}|rP||fVq
tjdt|ƒ›ttƒdq
dS)zÖ
        Generates (prop, value) pairs from declarations.
 
        In a future version may generate parsed tokens from tinycss/tinycss2
 
        Parameters
        ----------
        declarations_str : str
        ú;ú:z-Ill-formatted attribute: expected a colon in rN)    rÚstripÚ    partitionr/rrrxrr)rrˆÚdeclrÚseprir"r"r#r_Šs
    ýzCSSResolver.parse)N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__Z UNIT_RATIOSrgroÚupdaterwr6r4rrr%r‡rerarbrnrprcrmr7r_r"r"r"r#r;zs¤ôõÿüÿ ï
 
 
 
üþþþ÷ý6-
r;)r&)r’Ú
__future__rrÚtypingrrrrrZ pandas.errorsrZpandas.util._exceptionsrr%r:r;r"r"r"r#Ú<module>s   +<