a
    èÞJb¿  ã                   @   s"   d dl mZ G dd„ dejƒZdS )é   )Ú	xmlwriterc                       s¸   e Zd ZdZ‡ 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dd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Z‡  ZS )*ÚAppz8
    A class for writing the Excel XLSX App file.


    c                    s*   t t| ƒ ¡  g | _g | _i | _d| _dS )z
        Constructor.

        é    N)Úsuperr   Ú__init__Ú
part_namesÚheading_pairsÚ
propertiesÚdoc_security©Úself©Ú	__class__© ú-lib/python3.9/site-packages/xlsxwriter/app.pyr      s
    zApp.__init__c                 C   s   | j  |¡ d S ©N)r   Úappend)r   Ú	part_namer   r   r   Ú_add_part_name'   s    zApp._add_part_namec                 C   s8   |d sd S | j  d|d f¡ | j  d|d f¡ d S )Nr   Úlpstrr   Zi4)r   r   )r   Zheading_pairr   r   r   Ú_add_heading_pair+   s    zApp._add_heading_pairc                 C   s
   || _ d S r   )r	   )r   r	   r   r   r   Ú_set_properties6   s    zApp._set_propertiesc                 C   s†   |   ¡  |  ¡  |  ¡  |  ¡  |  ¡  |  ¡  |  ¡  |  ¡  |  ¡  |  	¡  |  
¡  |  ¡  |  ¡  |  ¡  |  d¡ |  ¡  d S )NÚ
Properties)Z_xml_declarationÚ_write_propertiesÚ_write_applicationÚ_write_doc_securityÚ_write_scale_cropÚ_write_heading_pairsÚ_write_titles_of_partsÚ_write_managerÚ_write_companyÚ_write_links_up_to_dateÚ_write_shared_docÚ_write_hyperlink_baseÚ_write_hyperlinks_changedÚ_write_app_versionÚ_xml_end_tagZ
_xml_closer   r   r   r   Ú_assemble_xml_file@   s     
zApp._assemble_xml_filec                 C   s4   d}|d }|d }d|fd|fg}|   d|¡ d S )Nz6http://schemas.openxmlformats.org/officeDocument/2006/zextended-propertiesZdocPropsVTypesÚxmlnszxmlns:vtr   )Ú_xml_start_tag)r   Zschemar(   Zxmlns_vtÚ
attributesr   r   r   r   _   s    þzApp._write_propertiesc                 C   s   |   dd¡ d S )NZApplicationzMicrosoft Excel©Ú_xml_data_elementr   r   r   r   r   l   s    zApp._write_applicationc                 C   s   |   d| j¡ d S )NZDocSecurity)r,   r
   r   r   r   r   r   p   s    zApp._write_doc_securityc                 C   s   |   dd¡ d S )NZ	ScaleCropÚfalser+   r   r   r   r   r   t   s    zApp._write_scale_cropc                 C   s&   |   d¡ |  d| j¡ |  d¡ d S )NZHeadingPairsÚvariant)r)   Ú_write_vt_vectorr   r&   r   r   r   r   r   x   s    
zApp._write_heading_pairsc                 C   sB   g }|   d¡ | jD ]}| d|f¡ q|  d|¡ |  d¡ d S )NZTitlesOfPartsr   )r)   r   r   r/   r&   )r   Z
parts_datar   r   r   r   r   ~   s    

zApp._write_titles_of_partsc                 C   sf   dt |ƒfd|fg}|  d|¡ |D ]2}|dkr:|  d¡ |  |¡ |dkr$|  d¡ q$|  d¡ d S )NÚsizeZbaseTypez	vt:vectorr.   z
vt:variant)Úlenr)   Ú_write_vt_datar&   )r   Z	base_typeZvector_datar*   Úvt_datar   r   r   r/   ‹   s    
þ

zApp._write_vt_vectorc                 C   s   |   d|d  |d ¡ d S )Nzvt:%sr   r   r+   )r   r3   r   r   r   r2   Ÿ   s    zApp._write_vt_datac                 C   s   | j  dd¡}|  d|¡ d S )NÚcompanyÚ ZCompany©r	   Úgetr,   )r   r4   r   r   r   r    £   s    zApp._write_companyc                 C   s$   d| j vrd S |  d| j d ¡ d S )NZmanagerZManager)r	   r,   r   r   r   r   r   ¨   s    
zApp._write_managerc                 C   s   |   dd¡ d S )NZLinksUpToDater-   r+   r   r   r   r   r!   ¯   s    zApp._write_links_up_to_datec                 C   s   |   dd¡ d S )NZ	SharedDocr-   r+   r   r   r   r   r"   ³   s    zApp._write_shared_docc                 C   s(   | j  d¡}|d u rd S |  d|¡ d S )NÚhyperlink_baseZHyperlinkBaser6   )r   r8   r   r   r   r#   ·   s    zApp._write_hyperlink_basec                 C   s   |   dd¡ d S )NZHyperlinksChangedr-   r+   r   r   r   r   r$   À   s    zApp._write_hyperlinks_changedc                 C   s   |   dd¡ d S )NZ
AppVersionz12.0000r+   r   r   r   r   r%   Ä   s    zApp._write_app_version)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r'   r   r   r   r   r   r   r/   r2   r    r   r!   r"   r#   r$   r%   Ú__classcell__r   r   r   r   r      s*   
	r   N)r5   r   Z	XMLwriterr   r   r   r   r   Ú<module>
   s   