
    >wgh                     F    d dl mZ ddlmZ  G d dej                        Zy)   )	xmlwriter    )warnc                       e Zd ZdZdH fd	Zd ZdIdZd ZdJdZdJdZ	dKdZ
dJd	ZdKd
ZdJdZdJdZd ZdJdZdJdZd ZdLdZdJdZd ZdKdZdJdZdJdZdKdZd Zd ZdKdZd ZdKdZd ZdKdZ dKdZ!d  Z"dKd!Z#d" Z$dKd#Z%d$ Z&d% Z'dKd&Z(dJd'Z)dJd(Z*dJd)Z+d* Z,d+ Z-d, Z.d- Z/d. Z0d/ Z1dMd0Z2d1 Z3d2 Z4d3 Z5d4 Z6d5 Z7d6 Z8d7 Z9dJd8Z:d9 Z;dJd:Z<d; Z=d< Z>d= Z?d> Z@d? ZAd@ ZBdA ZCdB ZDdC ZEdD ZFdE ZGdF ZHdG ZI xZJS )NFormatz;
    A class for writing the Excel XLSX Format file.


    c                    |i }t         t        |           || _        || _        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| _*        d| _+        d| _,        d| _-        d| _.        d| _/        d| _0        d| _1        d| _2        d| _3        d| _4        d| _5        d| _6        d| _7        d| _8        d| _9        d| _:        d| _;        d| _<        d| _=        d| _>        d| _?        d| _@        d| _A        d| _B        |j                         D ]  \  }} t        | d
|z         |        d| _E        y)z
        Constructor.

        NGeneralr   Calibri      minorFr   set_)Fsuperr   __init__xf_format_indicesdxf_format_indicesxf_index	dxf_index
num_formatnum_format_index
font_indexhas_fonthas_dxf_fontbold	underlineitalic	font_name	font_size
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
fill_index
fill_countborder_index
has_borderhas_dxf_borderborder_countbottombottom_colordiag_border
diag_color	diag_typeleft
left_colorrightright_colortop	top_colorindentshrinkmerge_rangereading_orderjust_distribcolor_indexed	font_onlyquote_prefixitemsgetattr_format_key)self
properties
xf_indicesdxf_indiceskeyvalue	__class__s         H/var/www/horilla/myenv/lib/python3.12/site-packages/xlsxwriter/format.pyr   zFormat.__init__   s6   
 Jfd$&!+"-# !	""

	
! %**, 	/JC'GD&3,'.	/      c                     || _         y)z
        Set the Format font_name property such as 'Time New Roman'. The
        default Excel font is 'Calibri'.

        Args:
            font_name: String with the font name. No default.

        Returns:
            Nothing.

        Nr   rT   r   s     r[   set_font_namezFormat.set_font_name{   s     #r\   c                     || _         y)z
        Set the Format font_size property. The default Excel font size is 11.

        Args:
            font_size: Int with font size. No default.

        Returns:
            Nothing.

        Nr   rT   r   s     r[   set_font_sizezFormat.set_font_size        #r\   c                 0    | j                  |      | _        y)z
        Set the Format font_color property. The Excel default is black.

        Args:
            font_color: String with the font color. No default.

        Returns:
            Nothing.

        N
_get_colorr   rT   r   s     r[   set_font_colorzFormat.set_font_color        //*5r\   c                     || _         y)z
        Set the Format bold property.

        Args:
            bold: Default is True, turns property on.

        Returns:
            Nothing.

        N)r   )rT   r   s     r[   set_boldzFormat.set_bold        	r\   c                     || _         y)z
        Set the Format italic property.

        Args:
            italic: Default is True, turns property on.

        Returns:
            Nothing.

        N)r   )rT   r   s     r[   
set_italiczFormat.set_italic        r\   c                     || _         y)z
        Set the Format underline property.

        Args:
            underline: Default is 1, single underline.

        Returns:
            Nothing.

        N)r   )rT   r   s     r[   set_underlinezFormat.set_underline   re   r\   c                     || _         y)z
        Set the Format font_strikeout property.

        Args:
            font_strikeout: Default is True, turns property on.

        Returns:
            Nothing.

        N)r    )rT   r    s     r[   set_font_strikeoutzFormat.set_font_strikeout   s     -r\   c                     || _         y)z
        Set the Format font_script property.

        Args:
            font_script: Default is 1, superscript.

        Returns:
            Nothing.

        N)r#   )rT   r#   s     r[   set_font_scriptzFormat.set_font_script        'r\   c                     || _         y)z
        Set the Format font_outline property.

        Args:
            font_outline: Default is True, turns property on.

        Returns:
            Nothing.

        N)r!   )rT   r!   s     r[   set_font_outlinezFormat.set_font_outline        )r\   c                     || _         y)z
        Set the Format font_shadow property.

        Args:
            font_shadow: Default is True, turns property on.

        Returns:
            Nothing.

        N)r"   )rT   r"   s     r[   set_font_shadowzFormat.set_font_shadow   rx   r\   c                     || _         y)z
        Set the Format num_format property such as '#,##0'.

        Args:
            num_format: String representing the number format. No default.

        Returns:
            Nothing.

        N)r   )rT   r   s     r[   set_num_formatzFormat.set_num_format   s     %r\   c                     || _         y)z
        Set the Format locked property.

        Args:
            locked: Default is True, turns property on.

        Returns:
            Nothing.

        N)r-   )rT   r-   s     r[   
set_lockedzFormat.set_locked  rq   r\   c                     || _         y)z
        Set the Format hidden property.

        Args:
            hidden: Default is True, turns property on.

        Returns:
            Nothing.

        N)r,   )rT   r,   s     r[   
set_hiddenzFormat.set_hidden  rq   r\   c                    |j                         }|dk(  r| j                  d       |dk(  r| j                  d       |dk(  r| j                  d       |dk(  r| j                  d       |dk(  r| j                  d	       |d
k(  r| j                  d       |dk(  r| j                  d       |dk(  r| j                  d       |dk(  r| j                  d       |dk(  r| j                  d       |dk(  rd| _        |dk(  r| j                  d       |dk(  r| j                  d       |dk(  r| j                  d       |dk(  r| j                  d       |dk(  r| j                  d	       |dk(  r| j                  d       yy)z
        Set the Format cell alignment.

        Args:
            alignment: String representing alignment. No default.

        Returns:
            Nothing.
        rC   r   centrer   centerrE      fill   justify   center_across   centre_acrossdistributed   justify_distributedrG   vcentrevcenterr>   vjustifyvdistributedN)lowerset_text_h_alignrM   set_text_v_align)rT   	alignments     r[   	set_alignzFormat.set_align%  s    OO%	 !!!$ !!!$ !!!$!!!$!!!$	!!!!$'!!!$'!!!$%!!!$--!!!$-- !D !!!$	!!!!$	!!!!$ !!!$
"!!!$&!!!$ 'r\   c                 &    | j                  d       y)z`
        Set the Format center_across property.

        Returns:
            Nothing.

        r   N)r   )rT   
align_types     r[   set_center_acrosszFormat.set_center_acrossX  s     	a r\   c                     || _         y)z
        Set the Format text_wrap property.

        Args:
            text_wrap: Default is True, turns property on.

        Returns:
            Nothing.

        N)r/   )rT   r/   s     r[   set_text_wrapzFormat.set_text_wrapb  re   r\   c                     t        |      }|dk(  r
d}|| _        yd|cxk  rdk  rn n|dk  r| dz   }|| _        yt        d       y|| _        y)z
        Set the Format rotation property.

        Args:
            rotation: Rotation angle. No default.

        Returns:
            Nothing.

        i     iZ   r   z3Rotation rotation outside range: -90 <= angle <= 90N)intr   r2   )rT   r2   s     r[   set_rotationzFormat.set_rotationo  sc     x= s?H ! H""!|$9r>
 ! FG r\   c                     || _         y)z
        Set the Format indent property.

        Args:
            indent: Default is 1, first indentation level.

        Returns:
            Nothing.

        N)rI   )rT   rI   s     r[   
set_indentzFormat.set_indent  rq   r\   c                     || _         y)z
        Set the Format shrink property.

        Args:
            shrink: Default is True, turns property on.

        Returns:
            Nothing.

        N)rJ   )rT   rJ   s     r[   
set_shrinkzFormat.set_shrink  rq   r\   c                     || _         y)z
        Set the Format text_justlast property.

        Args:
            text_justlast: Default is True, turns property on.

        Returns:
            Nothing.

        N)r1   )rT   r1   s     r[   set_text_justlastzFormat.set_text_justlast  s     +r\   c                     || _         y)z
        Set the Format pattern property.

        Args:
            pattern: Default is 1, solid fill.

        Returns:
            Nothing.

        N)r5   )rT   r5   s     r[   set_patternzFormat.set_pattern  s     r\   c                 0    | j                  |      | _        y)z
        Set the Format bg_color property.

        Args:
            bg_color: Background color. No default.

        Returns:
            Nothing.

        N)rh   r4   )rT   r4   s     r[   set_bg_colorzFormat.set_bg_color       1r\   c                 0    | j                  |      | _        y)z
        Set the Format fg_color property.

        Args:
            fg_color: Foreground color. No default.

        Returns:
            Nothing.

        N)rh   r3   )rT   r3   s     r[   set_fg_colorzFormat.set_fg_color  r   r\   c                     | j                  |       | j                  |       | j                  |       | j                  |       yz
        Set the Format bottom property.

        Args:
            bottom: Default is 1, border type 1.

        Returns:
            Nothing.

        N)
set_bottomset_topset_left	set_right)rT   styles     r[   
set_borderzFormat.set_border  s4     	Ueur\   c                     | j                  |       | j                  |       | j                  |       | j                  |       y)z
        Set the Format bottom property.

        Args:
            color: Color string. No default.

        Returns:
            Nothing.

        N)set_bottom_colorset_top_colorset_left_colorset_right_color)rT   colors     r[   set_border_colorzFormat.set_border_color  s<     	e$5!E"U#r\   c                     || _         yr   )r>   )rT   r>   s     r[   r   zFormat.set_bottom  rq   r\   c                 0    | j                  |      | _        y)z
        Set the Format bottom_color property.

        Args:
            bottom_color: Color string. No default.

        Returns:
            Nothing.

        N)rh   r?   )rT   r?   s     r[   r   zFormat.set_bottom_color  s     !OOL9r\   c                     || _         y)z
        Set the Format diag_type property.

        Args:
            diag_type: Default is 1, border type 1.

        Returns:
            Nothing.

        N)rB   )rT   rB   s     r[   set_diag_typezFormat.set_diag_type  re   r\   c                     || _         y)z
        Set the Format left property.

        Args:
            left: Default is 1, border type 1.

        Returns:
            Nothing.

        N)rC   )rT   rC   s     r[   r   zFormat.set_left  rn   r\   c                 0    | j                  |      | _        y)z
        Set the Format left_color property.

        Args:
            left_color: Color string. No default.

        Returns:
            Nothing.

        N)rh   rD   )rT   rD   s     r[   r   zFormat.set_left_color,  rk   r\   c                     || _         y)z
        Set the Format right property.

        Args:
            right: Default is 1, border type 1.

        Returns:
            Nothing.

        N)rE   )rT   rE   s     r[   r   zFormat.set_right9  s     
r\   c                 0    | j                  |      | _        y)z
        Set the Format right_color property.

        Args:
            right_color: Color string. No default.

        Returns:
            Nothing.

        N)rh   rF   )rT   rF   s     r[   r   zFormat.set_right_colorF  s      ??;7r\   c                     || _         y)z
        Set the Format top property.

        Args:
            top: Default is 1, border type 1.

        Returns:
            Nothing.

        N)rG   )rT   rG   s     r[   r   zFormat.set_topS  s     r\   c                 0    | j                  |      | _        y)z
        Set the Format top_color property.

        Args:
            top_color: Color string. No default.

        Returns:
            Nothing.

        N)rh   rH   )rT   rH   s     r[   r   zFormat.set_top_color`  s     3r\   c                 0    | j                  |      | _        y)z
        Set the Format diag_color property.

        Args:
            diag_color: Color string. No default.

        Returns:
            Nothing.

        N)rh   rA   )rT   rA   s     r[   set_diag_colorzFormat.set_diag_colorm  rk   r\   c                     || _         y)z
        Set the Format diag_border property.

        Args:
            diag_border: Default is 1, border type 1.

        Returns:
            Nothing.

        N)r@   )rT   r@   s     r[   set_diag_borderzFormat.set_diag_borderz  rx   r\   c                     || _         y)z
        Set the Format quote prefix property.

        Args:
            quote_prefix: Default is True, turns property on.

        Returns:
            Nothing.

        N)rP   )rT   rP   s     r[   set_quote_prefixzFormat.set_quote_prefix  r{   r\   c                     || _         y N)r   )rT   r   s     r[   set_has_fontzFormat.set_has_font  	     r\   c                     || _         y r   )r6   )rT   r6   s     r[   set_has_fillzFormat.set_has_fill  r   r\   c                     || _         y r   )r   )rT   r   s     r[   set_font_indexzFormat.set_font_index  s	    $r\   c                     || _         y r   )r   )rT   r   s     r[   set_xf_indexzFormat.set_xf_index  r   r\   c                     || _         y r   )r   )rT   r   s     r[   set_dxf_indexzFormat.set_dxf_index  	    "r\   c                     || _         y r   )r   )rT   r   s     r[   set_num_format_indexzFormat.set_num_format_index  s
     0r\   c                     || _         y r   )r.   )rT   r.   s     r[   r   zFormat.set_text_h_align  
    (r\   c                     || _         y r   )r0   )rT   r0   s     r[   r   zFormat.set_text_v_align  r   r\   c                     || _         y r   )rL   )rT   	directions     r[   set_reading_orderzFormat.set_reading_order  s
    &r\   c                 &    | j                  |       y r   )r   )rT   aligns     r[   
set_valignzFormat.set_valign  s     	ur\   c                     || _         y r   )r$   )rT   r$   s     r[   set_font_familyzFormat.set_font_family  
    &r\   c                     || _         y r   )r%   )rT   r%   s     r[   set_font_charsetzFormat.set_font_charset  r   r\   c                     || _         y r   )r&   )rT   r&   s     r[   set_font_schemezFormat.set_font_scheme  r   r\   c                     || _         y r   )r'   )rT   r'   s     r[   set_font_condensezFormat.set_font_condense  s
    *r\   c                     || _         y r   )r(   )rT   r(   s     r[   set_font_extendzFormat.set_font_extend  r   r\   c                     || _         y r   )r)   )rT   r)   s     r[   	set_themezFormat.set_theme  s	    
r\   c                 d    d| _         | j                  d       | j                  d       || _        y )Nr   
   )r+   rs   r   r*   )rT   r*   s     r[   set_hyperlinkzFormat.set_hyperlink  s,     
1r"r\   c                     || _         y r   )rN   )rT   color_indexs     r[   set_color_indexedzFormat.set_color_indexed  s
    (r\   c                     || _         y r   )rO   )rT   rO   s     r[   set_font_onlyzFormat.set_font_only  r   r\   c                     || _         y r   r^   r_   s     r[   set_fontzFormat.set_font  r   r\   c                     || _         y r   rb   rc   s     r[   set_sizezFormat.set_size  r   r\   c                 0    | j                  |      | _        y r   rg   ri   s     r[   	set_colorzFormat.set_color  s    //*5r\   c                 8   d}g }| j                   sH| j                  s<| j                  s0| j                  s$| j                  s| j
                  s| j                  rd}n||fS | j                  ra| j                   dk7  rR| j                   dk7  rC| j                   dk7  r4| j                  dk7  r%| j                  dk7  r| j                  dk7  rd| _         | j                  rd| _        | j                   dk(  rd| _        | j                   dk(  rd| _        | j                   dk(  rd| _        | j                   dk7  rd| _        | j                  rd| _        d}| j                   dk(  r|j                  d       | j                   d	k(  r|j                  d
       | j                   dk(  r|j                  d       | j                   dk(  r|j                  d       | j                   dk(  r|j                  d       | j                   dk(  r|j                  d|f       | j                   dk(  r|j                  d       | j                  r|j                  d       | j                  dk(  r|j                  d       | j                  d	k(  r|j                  d       | j                  dk(  r|j                  d       | j                  dk(  r|j                  d       | j                  r|j                  d| j                  f       | j                  r|j                  d| j                  f       | j                  r|j                  d       | j
                  r|j                  d       | j                  dk(  r|j                  d       | j                  d	k(  r|j                  d       ||fS )Nr   r   r   r   r   r   centerContinuous)
horizontalrC   r   )r  r   )r  rE   )r  r   )r  r   r   r  )r  r   )justifyLastLiner   )verticalrG   )r  r   )r  r   )r  r   textRotationrI   )wrapTextr   )shrinkToFitr   )readingOrderr   )r  r   )	r.   r0   rI   r2   r/   rJ   rL   rM   append)rT   changedr   
continuouss       r[   _get_align_propertieszFormat._get_align_properties   s      {{}}~~{{!!GE>! KK!!Q&!!Q&!!Q&!!Q&!!Q&!!Q& !D >>DK!DK!DK!DK! !D;; !D'
!LL/0!LL12!LL01!LL/0!LL23!LL,
34!LL67LL/0 !LL,-!LL/0!LL01!LL45==LL.$--89;;LL(DKK01>>LL);;LL+,"LL,-"LL,-~r\   c                 ~    g }| j                   s|j                  d       | j                  r|j                  d       |S )N)r-   r   )r,   r   )r-   r  r,   )rT   attribss     r[   _get_protection_propertiesz!Format._get_protection_properties_  s2    {{NN=);;NN=)r\   c                 <   | j                   dj                  d | j                         | j                         | j	                         | j                         | j                  | j                  | j                  | j                  fD              | _         | j                   S )N:c              3   2   K   | ]  }t        |        y wr   str.0xs     r[   	<genexpr>z)Format._get_format_key.<locals>.<genexpr>m  s      ( A(   )
rS   join_get_font_key_get_border_key_get_fill_key_get_alignment_keyr   r-   rP   r,   )rT   s    r[   _get_format_keyzFormat._get_format_keyj  s    #"xx ( &&(((*&&(++-OOKK%%KK	(  D r\   c                 T   dj                  d | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  | j                  fD              }|S )Nr  c              3   2   K   | ]  }t        |        y wr   r  r  s     r[   r  z'Format._get_font_key.<locals>.<genexpr>  s      
 F
r  )r  r   r   r%   r$   r!   r#   r"   r    r   r   r   r   r)   rT   rX   s     r[   r  zFormat._get_font_key}  s    hh 
 		!!  !!    ##


 
& 
r\   c                 (   dj                  d | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  | j                  | j                  fD              }|S )Nr  c              3   2   K   | ]  }t        |        y wr   r  r  s     r[   r  z)Format._get_border_key.<locals>.<genexpr>  s      
 F
r  )r  r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   r&  s     r[   r   zFormat._get_border_key  s{    hh 
 !!  		

  
 
" 
r\   c                 x    dj                  d | j                  | j                  | j                  fD              }|S )Nr  c              3   2   K   | ]  }t        |        y wr   r  r  s     r[   r  z'Format._get_fill_key.<locals>.<genexpr>  s     T!s1vTr  )r  r5   r4   r3   r&  s     r[   r!  zFormat._get_fill_key  s.    hhTdmmT]]'STT
r\   c           
          dj                  d | j                  | j                  | j                  | j                  | j
                  | j                  | j                  fD              }|S )Nr  c              3   2   K   | ]  }t        |        y wr   r  r  s     r[   r  z,Format._get_alignment_key.<locals>.<genexpr>  s      
 F
r  )r  r.   r0   rI   r2   r/   rJ   rL   r&  s     r[   r"  zFormat._get_alignment_key  sa     hh 
 !!!!""
 
 
r\   c                     | j                   | j                   S | j                         }|| j                  v r| j                  |   S dt        | j                        z   }|| j                  |<   || _         |S )Nr   )r   r#  r   lenrT   rX   indexs      r[   _get_xf_indexzFormat._get_xf_index  sx    ==$==  &&(Cd,,,--c22 C 6 677.3&&s+ %r\   c                     | j                   | j                   S | j                         }|| j                  v r| j                  |   S t        | j                        }|| j                  |<   || _         |S r   )r   r#  r   r.  r/  s      r[   _get_dxf_indexzFormat._get_dxf_index  ss    >>%>>! &&(Cd---..s33 D334/4'',!&r\   c                     i 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!}||v r||   }|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#FFFF00	automatic	Automatic )rT   r   named_colorss      r[   rh   zFormat._get_color  s    
Y
I
 Y
 I	

 I
 Y
 I
 y
 I
 i
 I
 i
 9
 i
 Y
  i!
" #
( L  'Er\   )NNN)r   )T)r   r   )r   )K__name__
__module____qualname____doc__r   r`   rd   rj   rm   rp   rs   ru   rw   rz   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  r#  r  r   r!  r"  r1  r3  rh   __classcell__)rZ   s   @r[   r   r      sk   X @##6#-')'%1%f!#!2+22"$ :#6846')(!!%!#1))'')'+'#)#
##6]~	 &.*$(&r\   r   N) r   warningsr   	XMLwriterr   rG  r\   r[   <module>rQ     s!     uY   ur\   