/ lib / xlsxwriter / format.pyc
format.pyc
  1  o

  2  P��c|e�@s.ddlmZddlmZGdd�dej�ZdS)�)�	xmlwriter�)�warncszeZdZdZd��fdd�	Zdd�Zd�dd	�Zd
  3  d�Zd�d
d�Zd�dd�Z	d�dd�Z
  4  d�dd�Zd�dd�Zd�dd�Z
d�dd�Zdd�Zd�dd�Zd�d d!�Zd"d#�Zd�d$d%�Zd�d&d'�Zd(d)�Zd�d*d+�Zd�d,d-�Zd�d.d/�Zd�d0d1�Zd2d3�Zd4d5�Zd�d6d7�Zd8d9�Zd�d:d;�Zd<d=�Zd�d>d?�Z d�d@dA�Z!dBdC�Z"d�dDdE�Z#dFdG�Z$d�dHdI�Z%dJdK�Z&dLdM�Z'd�dNdO�Z(d�dPdQ�Z)d�dRdS�Z*dTdU�Z+dVdW�Z,dXdY�Z-dZd[�Z.d\d]�Z/d^d_�Z0d�dadb�Z1dcdd�Z2dedf�Z3dgdh�Z4didj�Z5dkdl�Z6dmdn�Z7dodp�Z8d�dqdr�Z9dsdt�Z:d�dudv�Z;dwdx�Z<dydz�Z=d{d|�Z>d}d~�Z?dd��Z@d�d��ZAd�d��ZBd�d��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZH�ZIS)��Formatz;
  5      A class for writing the Excel XLSX Format file.
  6  
  7  
  8      Ncs�|duri}tt|���||_||_d|_d|_d|_d|_d|_	d|_
  9  d|_d|_d|_
d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_d	|_d|_ d|_!d|_"d|_#d|_$d|_%d|_&d|_'d|_(d|_)d|_*d|_+d|_,d|_-d|_.d|_/d|_0d|_1d|_2d|_3d|_4d|_5d|_6d|_7d|_8d|_9d|_:d|_;d|_<d|_=d|_>d|_?d|_@d|_A|�B�D]
\}}tC|d
 10  |�|�q�d|_DdS)z
 11          Constructor.
 12  
 13          N�Generalr�Calibri���minorFr�set_)E�superr�__init__�xf_format_indices�dxf_format_indices�xf_index�	dxf_index�
 14  num_format�num_format_index�
 15  font_index�has_font�has_dxf_font�bold�	underline�italic�	font_name�	font_size�
 16  font_color�font_strikeout�font_outline�font_shadow�font_script�font_family�font_charset�font_scheme�
font_condense�font_extend�theme�	hyperlink�xf_id�hidden�locked�text_h_align�	text_wrap�text_v_align�
text_justlast�rotation�fg_color�bg_color�pattern�has_fill�has_dxf_fill�
 17  fill_index�
 18  fill_count�border_index�
 19  has_border�has_dxf_border�border_count�bottom�bottom_color�diag_border�
 20  diag_color�	diag_type�left�
 21  left_color�right�right_color�top�	top_color�indent�shrink�merge_range�
reading_order�just_distrib�
color_indexed�	font_only�items�getattr�_format_key)�self�
 22  propertiesZ
 23  xf_indicesZdxf_indices�key�value��	__class__���C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\xlsxwriter\format.pyr
s�
 24  zFormat.__init__cC�
 25  ||_dS)z�
 26          Set the Format font_name property such as 'Time New Roman'. The
 27          default Excel font is 'Calibri'.
 28  
 29          Args:
 30              font_name: String with the font name. No default.
 31  
 32          Returns:
 33              Nothing.
 34  
 35          N�r�rPrrVrVrW�
set_font_nameys
 36  zFormat.set_font_namercCrX)z�
 37          Set the Format font_size property. The default Excel font size is 11.
 38  
 39          Args:
 40              font_size: Int with font size. No default.
 41  
 42          Returns:
 43              Nothing.
 44  
 45          N�r�rPrrVrVrW�
set_font_size��
 46  zFormat.set_font_sizecC�|�|�|_dS)z�
 47          Set the Format font_color property. The Excel default is black.
 48  
 49          Args:
 50              font_color: String with the font color. No default.
 51  
 52          Returns:
 53              Nothing.
 54  
 55          N��
 56  _get_colorr�rPrrVrVrW�set_font_color��zFormat.set_font_colorTcCrX)z�
 57          Set the Format bold property.
 58  
 59          Args:
 60              bold: Default is True, turns property on.
 61  
 62          Returns:
 63              Nothing.
 64  
 65          N)r)rPrrVrVrW�set_bold�r_zFormat.set_boldcCrX)z�
 66          Set the Format italic property.
 67  
 68          Args:
 69              italic: Default is True, turns property on.
 70  
 71          Returns:
 72              Nothing.
 73  
 74          N)r)rPrrVrVrW�
 75  set_italic�r_zFormat.set_italicrcCrX)z�
 76          Set the Format underline property.
 77  
 78          Args:
 79              underline: Default is 1, single underline.
 80  
 81          Returns:
 82              Nothing.
 83  
 84          N)r)rPrrVrVrW�
set_underline�r_zFormat.set_underlinecCrX)z�
 85          Set the Format font_strikeout property.
 86  
 87          Args:
 88              font_strikeout: Default is True, turns property on.
 89  
 90          Returns:
 91              Nothing.
 92  
 93          N)r)rPrrVrVrW�set_font_strikeout�r_zFormat.set_font_strikeoutcCrX)z�
 94          Set the Format font_script property.
 95  
 96          Args:
 97              font_script: Default is 1, superscript.
 98  
 99          Returns:
100              Nothing.
101  
102          N)r )rPr rVrVrW�set_font_script�r_zFormat.set_font_scriptcCrX)z�
103          Set the Format font_outline property.
104  
105          Args:
106              font_outline: Default is True, turns property on.
107  
108          Returns:
109              Nothing.
110  
111          N)r)rPrrVrVrW�set_font_outline�r_zFormat.set_font_outlinecCrX)z�
112          Set the Format font_shadow property.
113  
114          Args:
115              font_shadow: Default is True, turns property on.
116  
117          Returns:
118              Nothing.
119  
120          N)r)rPrrVrVrW�set_font_shadow�r_zFormat.set_font_shadowcCrX)z�
121          Set the Format num_format property such as '#,##0'.
122  
123          Args:
124              num_format: String representing the number format. No default.
125  
126          Returns:
127              Nothing.
128  
129          N)r)rPrrVrVrW�set_num_format�r_zFormat.set_num_formatcCrX)z�
130          Set the Format locked property.
131  
132          Args:
133              locked: Default is True, turns property on.
134  
135          Returns:
136              Nothing.
137  
138          N)r*)rPr*rVrVrW�
139  set_locked	r_zFormat.set_lockedcCrX)z�
140          Set the Format hidden property.
141  
142          Args:
143              hidden: Default is True, turns property on.
144  
145          Returns:
146              Nothing.
147  
148          N)r))rPr)rVrVrW�
149  set_hiddenr_zFormat.set_hiddencCs>|��}|dkr
|�d�|dkr|�d�|dkr|�d�|dkr(|�d�|dkr1|�d	�|d
150  kr:|�d�|dkrC|�d
�|dkrL|�d
�|dkrU|�d�|dkr^|�d�|dkred|_|dkrn|�d�|dkrw|�d�|dkr�|�d�|dkr�|�d�|dkr�|�d	�|dkr�|�d�dSdS)z�
151          Set the Format cell alignment.
152  
153          Args:
154              alignment: String representing alignment. No default.
155  
156          Returns:
157              Nothing.
158          r@r�centrer	�centerrB��fill��justify�Z
center_across�Z
centre_across�distributed�Zjustify_distributedrDZvcentre�vcenterr;ZvjustifyZvdistributedN)�lower�set_text_h_alignrJ�set_text_v_align)rP�	alignmentrVrVrW�	set_align#sH
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  �zFormat.set_aligncCs|�d�dS)z`
175          Set the Format center_across property.
176  
177          Returns:
178              Nothing.
179  
180          rwN)r|)rP�
181  align_typerVrVrW�set_center_acrossVszFormat.set_center_acrosscCrX)z�
182          Set the Format text_wrap property.
183  
184          Args:
185              text_wrap: Default is True, turns property on.
186  
187          Returns:
188              Nothing.
189  
190          N)r,)rPr,rVrVrW�
set_text_wrap`r_zFormat.set_text_wrapcCsXt|�}|dkrd}nd|krdkr!nn
191  |dkr |d}ntd�dS||_dS)z�
192          Set the Format rotation property.
193  
194          Args:
195              rotation: Rotation angle. No default.
196  
197          Returns:
198              Nothing.
199  
200          i��i�����Zrz3Rotation rotation outside range: -90 <= angle <= 90N)�intrr/)rPr/rVrVrW�set_rotationms
201  �
202  zFormat.set_rotationcCrX)z�
203          Set the Format indent property.
204  
205          Args:
206              indent: Default is 1, first indentation level.
207  
208          Returns:
209              Nothing.
210  
211          N)rF)rPrFrVrVrW�
212  set_indent�r_zFormat.set_indentcCrX)z�
213          Set the Format shrink property.
214  
215          Args:
216              shrink: Default is True, turns property on.
217  
218          Returns:
219              Nothing.
220  
221          N)rG)rPrGrVrVrW�
222  set_shrink�r_zFormat.set_shrinkcCrX)z�
223          Set the Format text_justlast property.
224  
225          Args:
226              text_justlast: Default is True, turns property on.
227  
228          Returns:
229              Nothing.
230  
231          N)r.)rPr.rVrVrW�set_text_justlast�r_zFormat.set_text_justlastcCrX)z�
232          Set the Format pattern property.
233  
234          Args:
235              pattern: Default is 1, solid fill.
236  
237          Returns:
238              Nothing.
239  
240          N)r2)rPr2rVrVrW�set_pattern�r_zFormat.set_patterncCr`)z�
241          Set the Format bg_color property.
242  
243          Args:
244              bg_color: Background color. No default.
245  
246          Returns:
247              Nothing.
248  
249          N)rbr1)rPr1rVrVrW�set_bg_color�rezFormat.set_bg_colorcCr`)z�
250          Set the Format fg_color property.
251  
252          Args:
253              fg_color: Foreground color. No default.
254  
255          Returns:
256              Nothing.
257  
258          N)rbr0)rPr0rVrVrW�set_fg_color�rezFormat.set_fg_colorcC�,|�|�|�|�|�|�|�|�dS�z�
259          Set the Format bottom property.
260  
261          Args:
262              bottom: Default is 1, border type 1.
263  
264          Returns:
265              Nothing.
266  
267          N)�
268  set_bottom�set_top�set_left�	set_right)rP�stylerVrVrW�
269  set_border��
270  
271  
272  zFormat.set_bordercCr�)z�
273          Set the Format bottom property.
274  
275          Args:
276              color: Color string. No default.
277  
278          Returns:
279              Nothing.
280  
281          N)�set_bottom_color�
set_top_color�set_left_color�set_right_color)rP�colorrVrVrW�set_border_color�r�zFormat.set_border_colorcCrXr�)r;)rPr;rVrVrWr��r_zFormat.set_bottomcCr`)z�
282          Set the Format bottom_color property.
283  
284          Args:
285              bottom_color: Color string. No default.
286  
287          Returns:
288              Nothing.
289  
290          N)rbr<)rPr<rVrVrWr�rezFormat.set_bottom_colorcCrX)z�
291          Set the Format diag_type property.
292  
293          Args:
294              diag_type: Default is 1, border type 1.
295  
296          Returns:
297              Nothing.
298  
299          N)r?)rPr?rVrVrW�
set_diag_typer_zFormat.set_diag_typecCrX)z�
300          Set the Format left property.
301  
302          Args:
303              left: Default is 1, border type 1.
304  
305          Returns:
306              Nothing.
307  
308          N)r@)rPr@rVrVrWr�r_zFormat.set_leftcCr`)z�
309          Set the Format left_color property.
310  
311          Args:
312              left_color: Color string. No default.
313  
314          Returns:
315              Nothing.
316  
317          N)rbrA)rPrArVrVrWr�*rezFormat.set_left_colorcCrX)z�
318          Set the Format right property.
319  
320          Args:
321              right: Default is 1, border type 1.
322  
323          Returns:
324              Nothing.
325  
326          N)rB)rPrBrVrVrWr�7r_zFormat.set_rightcCr`)z�
327          Set the Format right_color property.
328  
329          Args:
330              right_color: Color string. No default.
331  
332          Returns:
333              Nothing.
334  
335          N)rbrC)rPrCrVrVrWr�DrezFormat.set_right_colorcCrX)z�
336          Set the Format top property.
337  
338          Args:
339              top: Default is 1, border type 1.
340  
341          Returns:
342              Nothing.
343  
344          N)rD)rPrDrVrVrWr�Qr_zFormat.set_topcCr`)z�
345          Set the Format top_color property.
346  
347          Args:
348              top_color: Color string. No default.
349  
350          Returns:
351              Nothing.
352  
353          N)rbrE)rPrErVrVrWr�^rezFormat.set_top_colorcCr`)z�
354          Set the Format diag_color property.
355  
356          Args:
357              diag_color: Color string. No default.
358  
359          Returns:
360              Nothing.
361  
362          N)rbr>)rPr>rVrVrW�set_diag_colorkrezFormat.set_diag_colorcCrX)z�
363          Set the Format diag_border property.
364  
365          Args:
366              diag_border: Default is 1, border type 1.
367  
368          Returns:
369              Nothing.
370  
371          N)r=)rPr=rVrVrW�set_diag_borderxr_zFormat.set_diag_bordercC�
372  ||_dS�N)r)rPrrVrVrW�set_has_font��
373  zFormat.set_has_fontcCr�r�)r3)rPr3rVrVrW�set_has_fill�r�zFormat.set_has_fillcCr�r�)r)rPrrVrVrW�set_font_index�r�zFormat.set_font_indexcCr�r�)r)rPrrVrVrW�set_xf_index�r�zFormat.set_xf_indexcCr�r�)r)rPrrVrVrW�
set_dxf_index�r�zFormat.set_dxf_indexcCr�r�)r)rPrrVrVrW�set_num_format_index�r�zFormat.set_num_format_indexcCr�r�)r+)rPr+rVrVrWr|�r�zFormat.set_text_h_aligncCr�r�)r-)rPr-rVrVrWr}�r�zFormat.set_text_v_alignrcCr�r�)rI)rP�	directionrVrVrW�set_reading_order�r�zFormat.set_reading_ordercCs|�|�dSr�)r)rP�alignrVrVrW�
374  set_valign�szFormat.set_valigncCr�r�)r!)rPr!rVrVrW�set_font_family�r�zFormat.set_font_familycCr�r�)r")rPr"rVrVrW�set_font_charset�r�zFormat.set_font_charsetcCr�r�)r#)rPr#rVrVrW�set_font_scheme�r�zFormat.set_font_schemecCr�r�)r$)rPr$rVrVrW�set_font_condense�r�zFormat.set_font_condensecCr�r�)r%)rPr%rVrVrW�set_font_extend�r�zFormat.set_font_extendcCr�r�)r&)rPr&rVrVrW�	set_theme�r�zFormat.set_themecCs$d|_|�d�|�d�||_dS)Nr�
375  )r(rhr�r')rPr'rVrVrW�
set_hyperlink�s
376  
377  
378  zFormat.set_hyperlinkcCr�r�)rK)rPZcolor_indexrVrVrW�set_color_indexed�r�zFormat.set_color_indexedcCr�r�)rL)rPrLrVrVrW�
set_font_only�r�zFormat.set_font_onlycCr�r�rYrZrVrVrW�set_font�r�zFormat.set_fontcCr�r�r\r]rVrVrW�set_size�r�zFormat.set_sizecCs|�|�|_dSr�rarcrVrVrW�	set_color�szFormat.set_colorcCs8d}g}|js|js|js|js|js|js|jrd}n||fS|jr5|jdkr5|jdkr5|jdkr5d|_|jr;d|_|jdkrCd|_|jdkrKd|_|jdkrSd|_|jdkr[d|_|jrad|_d}|jdkrm|�d�|jd	krw|�d
379  �|jdkr�|�d�|jdkr�|�d�|jdkr�|�d
�|jdkr�|�d|f�|jdkr�|�d�|jr�|�d�|jdkr�|�d�|jd	kr�|�d�|jdkr�|�d�|jdkr�|�d�|jr�|�d|jf�|jr�|�d|jf�|jr�|�d�|j�r|�d�|jdk�r
|�d�|jd	k�r|�d�||fS)Nrrrrryrtrv�centerContinuous)�
380  horizontalr@r	)r�rq)r�rB)r�rs)r�rurwr�)r�rx)�justifyLastLiner)�verticalrD)r�rq)r�ru)r�rxrF�textRotation)�wrapTextr)�shrinkToFitr)�readingOrderr)r�r	)	r+r-rFr/r,rGrIrJ�append)rP�changedr��
381  continuousrVrVrW�_get_align_properties�s�����
382  
383  
384  
385  
386  
387  
388  
389  
390  
391  
392  
393  
394  
395  
396  
397  
398  
399  
400  
401  
402  
403  
404  
405  
406  
407  
408  
409  
410  
411  
412  
413  
414  zFormat._get_align_propertiescCs(g}|js
415  |�d�|jr|�d�|S)N)r*r)r)r)r*r�r))rP�attribsrVrVrW�_get_protection_propertiesEs
416  
417  z!Format._get_protection_propertiesc
418  CsJ|jdur"d�dd�|��|��|��|��|j|j|jfD��|_|jS)N�:cs��|]}t|�VqdSr���str��.0�xrVrVrW�	<genexpr>S��z)Format._get_format_key.<locals>.<genexpr>)	rO�join�
_get_font_key�_get_border_key�
_get_fill_key�_get_alignment_keyrr*r))rPrVrVrW�_get_format_keyPs
419  
420  �	zFormat._get_format_keycCsLd�dd�|j|j|j|j|j|j|j|j|j	|j
421  |j|j|j
f
D��}|S)Nr�csr�r�r�r�rVrVrWr�`r�z'Format._get_font_key.<locals>.<genexpr>)r�rrr"r!rr rrrrrrr&�rPrRrVrVrWr�^s 
422  
423  �zFormat._get_font_keycCsDd�dd�|j|j|j|j|j|j|j|j|j	|j
424  |jfD��}|S)Nr�csr�r�r�r�rVrVrWr�sr�z)Format._get_border_key.<locals>.<genexpr>)r�r;r<r=r>r?r@rArBrCrDrEr�rVrVrWr�qs
425  
426  �
zFormat._get_border_keycCs$d�dd�|j|j|jfD��}|S)Nr�csr�r�r�r�rVrVrWr��r�z'Format._get_fill_key.<locals>.<genexpr>)r�r2r1r0r�rVrVrWr��s
427  
428  �zFormat._get_fill_keyc
429  Cs4d�dd�|j|j|j|j|j|j|jfD��}|S)Nr�csr�r�r�r�rVrVrWr��r�z,Format._get_alignment_key.<locals>.<genexpr>)r�r+r-rFr/r,rGrIr�rVrVrWr��s
430  
431  �	zFormat._get_alignment_keycCsN|jdur|jS|��}||jvr|j|Sdt|j�}||j|<||_|S)Nr)rr�r�len�rPrR�indexrVrVrW�
_get_xf_index�s
432  
433  
434  
435  zFormat._get_xf_indexcCsJ|jdur|jS|��}||jvr|j|St|j�}||j|<||_|Sr�)rr�rr�r�rVrVrW�_get_dxf_index�s
436  
437  
438  
439  
440  zFormat._get_dxf_indexcCsxidd�dd�dd�dd�d	d
441  �dd�d
d�dd�dd�dd�dd�dd�dd�dd�dd�dd�}||vr:||}|S) N�blackz#000000�bluez#0000FF�brownz#800000�cyanz#00FFFF�grayz#808080�greenz#008000�limez#00FF00�magentaz#FF00FF�navyz#000080�orangez#FF6600�pink�purplez#800080�redz#FF0000�silverz#C0C0C0�whitez#FFFFFF�yellowz#FFFF00rV)rPr��named_colorsrVrVrWrb�sH��������	�
442  ���
����zFormat._get_color)NNN)r)T)rr�)r)J�__name__�
443  __module__�__qualname__�__doc__r
r[r^rdrfrgrhrirjrkrlrmrnrorr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r|r}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rb�
__classcell__rVrVrTrWrs�^
444  
445  
446  
447  
448  
449  
450  
451  

452  
453  

454  3
455  
456  
457  
458  
459  
460  


461  
462  
463  
464  

465  

466  


467  
468  
469  
470  
471  
472  
473  T	rN)�r�warningsr�	XMLwriterrrVrVrVrW�<module>s