3
T'c                 @   st   d Z ddlmZ ddlmZ ddlZddlZddlmZ ddl	Z	ddl
Z
dddZd	d
 Zdd Zedkrpe  dS )z
Fix a word-processor-generated styles.odt for odtwriter use: Drop page size
specifications from styles.xml in STYLE_FILE.odt.
    )print_function)etreeN)mkstempz/urn:oasis:names:tc:opendocument:xmlns:style:1.0z;urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0)stylefoc       	      C   s   t j| }|jd}tj|}x@|jdtdD ].}x(|jD ]}|jdtd  r:|j|= q:W q.W t	 }t jt
j|d ddt j}xB|j D ]6}|jdkr|j|tj| q|j||j|j qW |j  |j  tj|d |  d S )	Nz
styles.xmlz//style:page-layout-properties)
namespacesz{%s}r   r   w   )zipfileZipFilereadr   
fromstringZxpath
NAMESPACESattrib
startswithr   osfdopenZIP_DEFLATEDinfolistfilenamewritestrtostringcloseshutilmove)	r   ZzinZstylesrootelattrtempnameZzoutitem r    S/tmp/pip-build-gk9425m9/docutils/docutils-0.17.1.data/scripts/rst2odt_prepstyles.py	prepstyle   s$    



r"   c              C   s^   t jdd  } t| dkrJttt jd tdt jd  t jd t jd | d }t| d S )Nr	   )filezUsage: %s STYLE_FILE.odt
r   )sysargvlenprint__doc__stderrexitr"   )argsr   r    r    r!   main8   s    
r,   __main__)r(   
__future__r   lxmlr   r$   r
   tempfiler   r   r   r   r"   r,   __name__r    r    r    r!   <module>
   s   
