B
    ±ªt\k  ã               @   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S )z
        Constructor.

        N)Úsuperr   Ú__init__Ú
part_namesÚheading_pairsÚ
properties)Úself)Ú	__class__© ú-lib/python3.7/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   Úlpstré    Zi4)r   r   )r	   Zheading_pairr   r   r   Ú_add_heading_pair)   s    zApp._add_heading_pairc             C   s
   || _ d S )N)r   )r	   r   r   r   r   Ú_set_properties4   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_close)r	   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_element)r	   r   r   r   r   j   s    zApp._write_applicationc             C   s   |   dd¡ d S )NZDocSecurityÚ0)r'   )r	   r   r   r   r   n   s    zApp._write_doc_securityc             C   s   |   dd¡ d S )NZ	ScaleCropÚfalse)r'   )r	   r   r   r   r   r   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   v   s    
zApp._write_heading_pairsc             C   sF   g }|   d¡ x| jD ]}| d|f¡ qW |  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   sj   dt |ƒfd|fg}|  d|¡ x:|D ]2}|dkr<|  d¡ |  |¡ |dkr&|  d¡ q&W |  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	   r/   r   r   r   r.      s    zApp._write_vt_datac             C   s   | j  dd¡}|  d|¡ d S )NÚcompanyÚ ZCompany)r   Úgetr'   )r	   r0   r   r   r   r   ¡   s    zApp._write_companyc             C   s$   d| j k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 krd S |  d|¡ d S )NÚhyperlink_baseZHyperlinkBase)r   r2   r'   )r	   r3   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.0000)r'   )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+   r.   r   r   r   r   r   r    r!   Ú__classcell__r   r   )r
   r   r      s*   
	r   N)r1   r   Z	XMLwriterr   r   r   r   r   Ú<module>	   s   