o
    ]oih                     @   s.   d dl mZ ddlmZ G dd dejZdS )   )	xmlwriter    )warnc                       s  e Zd ZdZd fdd	Zdd Zddd	Zd
d ZdddZdddZ	dddZ
dddZdddZdddZdddZdd ZdddZdd d!Zd"d# Zdd$d%Zdd&d'Zd(d) Zdd*d+Zdd,d-Zdd.d/Zdd0d1Zd2d3 Zd4d5 Zdd6d7Zd8d9 Zdd:d;Zd<d= Zdd>d?Z dd@dAZ!dBdC Z"ddDdEZ#dFdG Z$ddHdIZ%dJdK Z&dLdM Z'ddNdOZ(ddPdQZ)ddRdSZ*ddTdUZ+dVdW Z,dXdY Z-dZd[ Z.d\d] Z/d^d_ Z0d`da Z1ddcddZ2dedf Z3dgdh Z4didj Z5dkdl Z6dmdn Z7dodp Z8dqdr Z9ddsdtZ:dudv Z;ddwdxZ<dydz Z=d{d| Z>d}d~ Z?dd Z@dd ZAdd ZBdd ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZI  ZJS )Formatz;
    A class for writing the Excel XLSX Format file.


    Nc                    s  |du r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| _0d| _1d| _2d| _3d| _4d| _5d| _6d| _7d| _8d| _9d| _:d| _;d| _<d| _=d| _>d| _?d| _@d| _Ad| _B|C D ]\}}tD| d
| | qd| _EdS )z
        Constructor.

        NZGeneralr   ZCalibri      minorFr   Zset_)Fsuperr   __init__xf_format_indicesdxf_format_indicesxf_index	dxf_index
num_formatnum_format_index
font_indexhas_fontZ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_fillZhas_dxf_fillZ
fill_indexZ
fill_countZborder_indexZ
has_borderZhas_dxf_borderZborder_countbottombottom_colordiag_border
diag_color	diag_typeleft
left_colorrightright_colortop	top_colorindentshrinkZmerge_rangereading_orderjust_distribcolor_indexed	font_onlyquote_prefixitemsgetattr_format_key)self
propertiesZ
xf_indicesZdxf_indiceskeyvalue	__class__ Y/var/www/html/kuke-dev/django-kuke/venv/lib/python3.10/site-packages/xlsxwriter/format.pyr
      s   
zFormat.__init__c                 C   
   || _ dS )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   rE   r   rK   rK   rL   set_font_name{   s   
zFormat.set_font_namer   c                 C   rM   )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   rE   r   rK   rK   rL   set_font_size      
zFormat.set_font_sizec                 C      |  || _dS )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   rE   r   rK   rK   rL   set_font_color      zFormat.set_font_colorTc                 C   rM   )z
        Set the Format bold property.

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

        Returns:
            Nothing.

        N)r   )rE   r   rK   rK   rL   set_bold   rT   zFormat.set_boldc                 C   rM   )z
        Set the Format italic property.

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

        Returns:
            Nothing.

        N)r   )rE   r   rK   rK   rL   
set_italic   rT   zFormat.set_italicr   c                 C   rM   )z
        Set the Format underline property.

        Args:
            underline: Default is 1, single underline.

        Returns:
            Nothing.

        N)r   )rE   r   rK   rK   rL   set_underline   rT   zFormat.set_underlinec                 C   rM   )z
        Set the Format font_strikeout property.

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

        Returns:
            Nothing.

        N)r   )rE   r   rK   rK   rL   set_font_strikeout   rT   zFormat.set_font_strikeoutc                 C   rM   )z
        Set the Format font_script property.

        Args:
            font_script: Default is 1, superscript.

        Returns:
            Nothing.

        N)r   )rE   r   rK   rK   rL   set_font_script   rT   zFormat.set_font_scriptc                 C   rM   )z
        Set the Format font_outline property.

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

        Returns:
            Nothing.

        N)r   )rE   r   rK   rK   rL   set_font_outline   rT   zFormat.set_font_outlinec                 C   rM   )z
        Set the Format font_shadow property.

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

        Returns:
            Nothing.

        N)r   )rE   r   rK   rK   rL   set_font_shadow   rT   zFormat.set_font_shadowc                 C   rM   )z
        Set the Format num_format property such as '#,##0'.

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

        Returns:
            Nothing.

        N)r   )rE   r   rK   rK   rL   set_num_format   rT   zFormat.set_num_formatc                 C   rM   )z
        Set the Format locked property.

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

        Returns:
            Nothing.

        N)r&   )rE   r&   rK   rK   rL   
set_locked  rT   zFormat.set_lockedc                 C   rM   )z
        Set the Format hidden property.

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

        Returns:
            Nothing.

        N)r%   )rE   r%   rK   rK   rL   
set_hidden  rT   zFormat.set_hiddenc                 C   s>  |  }|dkr| d |dkr| d |dkr| d |dkr(| d |dkr1| d	 |d
kr:| d |dkrC| d |dkrL| d |dkrU| d |dkr^| d |dkred| _|dkrn| d |dkrw| d |dkr| d |dkr| d |dkr| d	 |dkr| d dS dS )z
        Set the Format cell alignment.

        Args:
            alignment: String representing alignment. No default.

        Returns:
            Nothing.
        r5   r   Zcentrer   centerr7      fill   justify   Zcenter_across   Zcentre_acrossdistributed   Zjustify_distributedr9   ZvcentreZvcenterr0   ZvjustifyZvdistributedN)lowerset_text_h_alignr>   set_text_v_align)rE   Z	alignmentrK   rK   rL   	set_align%  sH   















zFormat.set_alignc                 C   s   |  d dS )z`
        Set the Format center_across property.

        Returns:
            Nothing.

        rk   N)ro   )rE   Z
align_typerK   rK   rL   set_center_acrossX  s   zFormat.set_center_acrossc                 C   rM   )z
        Set the Format text_wrap property.

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

        Returns:
            Nothing.

        N)r(   )rE   r(   rK   rK   rL   set_text_wrapb  rT   zFormat.set_text_wrapc                 C   sX   t |}|dkrd}nd|  krdkr!n n
|dk r | d }ntd dS || _dS )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   r+   )rE   r+   rK   rK   rL   set_rotationo  s   

zFormat.set_rotationc                 C   rM   )z
        Set the Format indent property.

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

        Returns:
            Nothing.

        N)r;   )rE   r;   rK   rK   rL   
set_indent  rT   zFormat.set_indentc                 C   rM   )z
        Set the Format shrink property.

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

        Returns:
            Nothing.

        N)r<   )rE   r<   rK   rK   rL   
set_shrink  rT   zFormat.set_shrinkc                 C   rM   )z
        Set the Format text_justlast property.

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

        Returns:
            Nothing.

        N)r*   )rE   r*   rK   rK   rL   set_text_justlast  rT   zFormat.set_text_justlastc                 C   rM   )z
        Set the Format pattern property.

        Args:
            pattern: Default is 1, solid fill.

        Returns:
            Nothing.

        N)r.   )rE   r.   rK   rK   rL   set_pattern  rT   zFormat.set_patternc                 C   rU   )z
        Set the Format bg_color property.

        Args:
            bg_color: Background color. No default.

        Returns:
            Nothing.

        N)rW   r-   )rE   r-   rK   rK   rL   set_bg_color  rZ   zFormat.set_bg_colorc                 C   rU   )z
        Set the Format fg_color property.

        Args:
            fg_color: Foreground color. No default.

        Returns:
            Nothing.

        N)rW   r,   )rE   r,   rK   rK   rL   set_fg_color  rZ   zFormat.set_fg_colorc                 C   ,   |  | | | | | | | dS 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)rE   stylerK   rK   rL   
set_border     


zFormat.set_borderc                 C   r~   )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)rE   colorrK   rK   rL   set_border_color  r   zFormat.set_border_colorc                 C   rM   r   )r0   )rE   r0   rK   rK   rL   r     rT   zFormat.set_bottomc                 C   rU   )z
        Set the Format bottom_color property.

        Args:
            bottom_color: Color string. No default.

        Returns:
            Nothing.

        N)rW   r1   )rE   r1   rK   rK   rL   r     rZ   zFormat.set_bottom_colorc                 C   rM   )z
        Set the Format diag_type property.

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

        Returns:
            Nothing.

        N)r4   )rE   r4   rK   rK   rL   set_diag_type  rT   zFormat.set_diag_typec                 C   rM   )z
        Set the Format left property.

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

        Returns:
            Nothing.

        N)r5   )rE   r5   rK   rK   rL   r     rT   zFormat.set_leftc                 C   rU   )z
        Set the Format left_color property.

        Args:
            left_color: Color string. No default.

        Returns:
            Nothing.

        N)rW   r6   )rE   r6   rK   rK   rL   r   ,  rZ   zFormat.set_left_colorc                 C   rM   )z
        Set the Format right property.

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

        Returns:
            Nothing.

        N)r7   )rE   r7   rK   rK   rL   r   9  rT   zFormat.set_rightc                 C   rU   )z
        Set the Format right_color property.

        Args:
            right_color: Color string. No default.

        Returns:
            Nothing.

        N)rW   r8   )rE   r8   rK   rK   rL   r   F  rZ   zFormat.set_right_colorc                 C   rM   )z
        Set the Format top property.

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

        Returns:
            Nothing.

        N)r9   )rE   r9   rK   rK   rL   r   S  rT   zFormat.set_topc                 C   rU   )z
        Set the Format top_color property.

        Args:
            top_color: Color string. No default.

        Returns:
            Nothing.

        N)rW   r:   )rE   r:   rK   rK   rL   r   `  rZ   zFormat.set_top_colorc                 C   rU   )z
        Set the Format diag_color property.

        Args:
            diag_color: Color string. No default.

        Returns:
            Nothing.

        N)rW   r3   )rE   r3   rK   rK   rL   set_diag_colorm  rZ   zFormat.set_diag_colorc                 C   rM   )z
        Set the Format diag_border property.

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

        Returns:
            Nothing.

        N)r2   )rE   r2   rK   rK   rL   set_diag_borderz  rT   zFormat.set_diag_borderc                 C   rM   )z
        Set the Format quote prefix property.

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

        Returns:
            Nothing.

        N)rA   )rE   rA   rK   rK   rL   set_quote_prefix  rT   zFormat.set_quote_prefixc                 C   
   || _ d S N)r   )rE   r   rK   rK   rL   set_has_font     
zFormat.set_has_fontc                 C   r   r   )r/   )rE   r/   rK   rK   rL   set_has_fill  r   zFormat.set_has_fillc                 C   r   r   )r   )rE   r   rK   rK   rL   set_font_index  r   zFormat.set_font_indexc                 C   r   r   )r   )rE   r   rK   rK   rL   set_xf_index  r   zFormat.set_xf_indexc                 C   r   r   )r   )rE   r   rK   rK   rL   set_dxf_index  r   zFormat.set_dxf_indexc                 C   r   r   )r   )rE   r   rK   rK   rL   set_num_format_index  r   zFormat.set_num_format_indexc                 C   r   r   )r'   )rE   r'   rK   rK   rL   ro     r   zFormat.set_text_h_alignc                 C   r   r   )r)   )rE   r)   rK   rK   rL   rp     r   zFormat.set_text_v_alignr   c                 C   r   r   )r=   )rE   	directionrK   rK   rL   set_reading_order  r   zFormat.set_reading_orderc                 C   s   |  | d S r   )rq   )rE   alignrK   rK   rL   
set_valign  s   zFormat.set_valignc                 C   r   r   )r   )rE   r   rK   rK   rL   set_font_family  r   zFormat.set_font_familyc                 C   r   r   )r   )rE   r   rK   rK   rL   set_font_charset  r   zFormat.set_font_charsetc                 C   r   r   )r   )rE   r   rK   rK   rL   set_font_scheme  r   zFormat.set_font_schemec                 C   r   r   )r    )rE   r    rK   rK   rL   set_font_condense  r   zFormat.set_font_condensec                 C   r   r   )r!   )rE   r!   rK   rK   rL   set_font_extend  r   zFormat.set_font_extendc                 C   r   r   )r"   )rE   r"   rK   rK   rL   	set_theme  r   zFormat.set_themec                 C   s$   d| _ | d | d || _d S )Nr   
   )r$   r]   r   r#   )rE   r#   rK   rK   rL   set_hyperlink  s   


zFormat.set_hyperlinkc                 C   r   r   )r?   )rE   Zcolor_indexrK   rK   rL   set_color_indexed  r   zFormat.set_color_indexedc                 C   r   r   )r@   )rE   r@   rK   rK   rL   set_font_only  r   zFormat.set_font_onlyc                 C   r   r   rN   rO   rK   rK   rL   set_font  r   zFormat.set_fontc                 C   r   r   rQ   rR   rK   rK   rL   set_size  r   zFormat.set_sizec                 C   s   |  || _d S r   rV   rX   rK   rK   rL   	set_color  s   zFormat.set_colorc                 C   sZ  d}g }| j s| js| js| js| js| js| jrd}n||fS | jrD| j dkrD| j dkrD| j dkrD| jdkrD| jdkrD| jdkrDd| _ | jrJd| _| j dkrRd| _| j dkrZd| _| j dkrbd| _| j dkrjd| _| jrpd| _d}| j dkr||d | j d	kr|d
 | j dkr|d | j dkr|d | j dkr|d | j dkr|d|f | j dkr|d | jr|d | jdkr|d | jd	kr|d | jdkr|d | jdkr|d | jr|d| jf | jr|d| jf | jr
|d | jr|d | jdkr|d | jd	kr)|d ||fS )Nr   r   rf   rm   rj   rh   ZcenterContinuous)
horizontalr5   r   )r   re   )r   r7   )r   rg   )r   ri   rk   r   )r   rl   )ZjustifyLastLiner   )verticalr9   )r   re   )r   ri   )r   rl   ZtextRotationr;   )ZwrapTextr   )ZshrinkToFitr   )readingOrderr   )r   r   )	r'   r)   r;   r+   r(   r<   r=   r>   append)rE   changedr   Z
continuousrK   rK   rL   _get_align_properties   s   	



































zFormat._get_align_propertiesc                 C   s(   g }| j s
|d | jr|d |S )N)r&   r   )r%   r   )r&   r   r%   )rE   attribsrK   rK   rL   _get_protection_properties_  s   

z!Format._get_protection_propertiesc                 C   sN   | j d u r$ddd |  |  |  |  | j| j| j| j	fD | _ | j S )N:c                 s       | ]}t |V  qd S r   str.0xrK   rK   rL   	<genexpr>m  
    
z)Format._get_format_key.<locals>.<genexpr>)
rD   join_get_font_key_get_border_key_get_fill_key_get_alignment_keyr   r&   rA   r%   )rE   rK   rK   rL   _get_format_keyj  s   


zFormat._get_format_keyc                 C   sL   d dd | j| j| j| j| j| j| j| j| j	| j
| j| j| jfD }|S )Nr   c                 s   r   r   r   r   rK   rK   rL   r     r   z'Format._get_font_key.<locals>.<genexpr>)r   r   r   r   r   r   r   r   r   r   r   r   r   r"   rE   rG   rK   rK   rL   r   }  s"   
zFormat._get_font_keyc                 C   sD   d dd | j| j| j| j| j| j| j| j| j	| j
| jfD }|S )Nr   c                 s   r   r   r   r   rK   rK   rL   r     r   z)Format._get_border_key.<locals>.<genexpr>)r   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r   rK   rK   rL   r     s   
zFormat._get_border_keyc                 C   s$   d dd | j| j| jfD }|S )Nr   c                 s   r   r   r   r   rK   rK   rL   r     s    z'Format._get_fill_key.<locals>.<genexpr>)r   r.   r-   r,   r   rK   rK   rL   r     s    zFormat._get_fill_keyc              
   C   s4   d dd | j| j| j| j| j| j| jfD }|S )Nr   c                 s   r   r   r   r   rK   rK   rL   r     r   z,Format._get_alignment_key.<locals>.<genexpr>)r   r'   r)   r;   r+   r(   r<   r=   r   rK   rK   rL   r     s   
zFormat._get_alignment_keyc                 C   sN   | j d ur| j S |  }|| jv r| j| S dt| j }|| j|< || _ |S )Nr   )r   r   r   lenrE   rG   indexrK   rK   rL   _get_xf_index  s   



zFormat._get_xf_indexc                 C   sJ   | j d ur| j S |  }|| jv r| j| S t| j}|| j|< || _ |S r   )r   r   r   r   r   rK   rK   rL   _get_dxf_index  s   




zFormat._get_dxf_indexc                 C   s~   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#0000FFZbrownz#800000cyanz#00FFFFgrayz#808080greenz#008000Zlimez#00FF00magentaz#FF00FFZnavyz#000080Zorangez#FF6600Zpinkpurplez#800080redz#FF0000silverz#C0C0C0whitez#FFFFFFyellowz#FFFF00Z	automaticZ	AutomaticrK   )rE   r   Znamed_colorsrK   rK   rL   rW     sL   	
zFormat._get_color)NNN)r   )T)r   r   )r   )K__name__
__module____qualname____doc__r
   rP   rS   rY   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   rq   rr   rs   rw   rx   ry   rz   r{   r|   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ro   rp   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rW   __classcell__rK   rK   rI   rL   r      s    `










3



















_r   N) r   warningsr   Z	XMLwriterr   rK   rK   rK   rL   <module>   s   	