o
    öÑÐb±  ã                   @   s6   d dl Z ddlmZ ddlmZ G dd„ dejƒZdS )é    Né   )Ú	xmlwriter)Úxl_rowcol_to_cellc                       s”   e Zd ZdZ‡ fdd„Zg fdd„Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Z‡  ZS ) ÚCommentsz=
    A class for writing the Excel XLSX Comments file.


    c                    s   t t| ƒ ¡  i | _dS )z
        Constructor.

        N)Úsuperr   Ú__init__Ú
author_ids)Úself©Ú	__class__© úR/var/www/secure340b-portal/env/lib/python3.10/site-packages/xlsxwriter/comments.pyr      s   
zComments.__init__c                 C   s:   |   ¡  |  ¡  |  |¡ |  |¡ |  d¡ |  ¡  d S )NÚcomments)Z_xml_declarationÚ_write_commentsÚ_write_authorsÚ_write_comment_listÚ_xml_end_tagZ
_xml_close)r	   Zcomments_datar   r   r   Ú_assemble_xml_file*   s   


zComments._assemble_xml_filec                 C   s   d}d|fg}|   d|¡ d S )Nz9http://schemas.openxmlformats.org/spreadsheetml/2006/mainÚxmlnsr   )Ú_xml_start_tag)r	   r   Ú
attributesr   r   r   r   D   s   
zComments._write_commentsc                 C   s\   d}|   d¡ |D ]}|d }|d ur&|| jvr&|| j|< |d7 }|  |¡ q	|  d¡ d S )Nr   Zauthorsé   r   )r   r   Ú_write_authorr   )r	   Úcomment_dataZauthor_countÚcommentÚauthorr   r   r   r   L   s   


€zComments._write_authorsc                 C   s   |   d|¡ d S )Nr   )Ú_xml_data_element)r	   Údatar   r   r   r   _   s   zComments._write_authorc                 C   sŒ   |   d¡ |D ]7}|d }|d }|d }|d }|d }|d }|d }	d }
|d ur0| j| }
|||	f}|  ||||
|¡ q|  d¡ d S )	NZcommentListr   r   é   r   é   é   é   )r   r   Ú_write_commentr   )r	   r   r   ÚrowÚcolÚtextr   Ú	font_nameÚ	font_sizeÚfont_familyÚ	author_idÚfontr   r   r   r   c   s   


zComments._write_comment_listc                 C   sP   t ||ƒ}d|fg}|d ur| d|f¡ |  d|¡ |  ||¡ |  d¡ d S )NÚrefZauthorIdr   )r   Úappendr   Ú_write_textr   )r	   r#   r$   r%   r)   r*   r+   r   r   r   r   r"   {   s   

zComments._write_commentc                 C   s$   |   d¡ |  ||¡ |  d¡ d S )Nr%   )r   Ú_write_text_rr   ©r	   r%   r*   r   r   r   r-   ‹   s   
zComments._write_textc                 C   s,   |   d¡ |  |¡ |  |¡ |  d¡ d S )NÚr)r   Ú_write_r_prÚ_write_text_tr   r/   r   r   r   r.   ”   s   


zComments._write_text_rc                 C   s8   g }t  d|¡st  d|¡r| d¡ |  d||¡ d S )Nz^\sz\s$)z	xml:spaceÚpreserveÚt)ÚreÚsearchr,   r   )r	   r%   r   r   r   r   r2       s   
zComments._write_text_tc                 C   sJ   |   d¡ |  |d ¡ |  ¡  |  |d ¡ |  |d ¡ |  d¡ d S )NZrPrr   r   r   )r   Ú	_write_szÚ_write_colorÚ_write_r_fontÚ_write_familyr   )r	   r*   r   r   r   r1   ©   s   
zComments._write_r_prc                 C   ó   d|fg}|   d|¡ d S )NÚvalÚsz©Z_xml_empty_tag)r	   r'   r   r   r   r   r7   »   ó   
zComments._write_szc                 C   s   dg}|   d|¡ d S )N)ZindexedéQ   Úcolorr>   )r	   r   r   r   r   r8   Á   s   zComments._write_colorc                 C   r;   )Nr<   ZrFontr>   )r	   r&   r   r   r   r   r9   Ç   r?   zComments._write_r_fontc                 C   r;   )Nr<   Úfamilyr>   )r	   r(   r   r   r   r   r:   Í   r?   zComments._write_family)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r"   r-   r.   r2   r1   r7   r8   r9   r:   Ú__classcell__r   r   r
   r   r      s"    		r   )r5   Ú r   Zutilityr   Z	XMLwriterr   r   r   r   r   Ú<module>   s   