3

T'íc´ã@stdZddlmZddlmZddlZddlZddlmZddl	Z	ddl
Z
dddœZd	d
„Zdd„Z
ed
krpe
ƒdS)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	Csêtj|ƒ}|jdƒ}tj|ƒ}x@|jdtdD].}x(|jD]}|jdtdƒr:|j|=q:Wq.Wt	ƒ}tjt
j|ddƒdtjƒ}xB|j
ƒD]6}|jdkr®|j|tj|ƒƒqŒ|j||j|jƒƒqŒW|jƒ|jƒtj|d|ƒdS)	Nz
styles.xmlz//style:page-layout-properties)Ú
namespacesz{%s}rrÚwé)ÚzipfileÚZipFileÚreadrÚ
fromstringZxpathÚ
NAMESPACESÚattribÚ
startswithrÚosÚfdopenÚZIP_DEFLATEDÚinfolistÚfilenameÚwritestrÚtostringÚcloseÚshutilÚmove)	rZzinZstylesÚrootÚelÚattrÚtempnameZzoutÚitem©r úS/tmp/pip-build-gk9425m9/docutils/docutils-0.17.1.data/scripts/rst2odt_prepstyles.pyÚ	prepstyles$



r"cCs^tjdd…}t|ƒdkrJtttjdtdtjdtjdtjdƒ|d}t|ƒdS)Nr	)ÚfilezUsage: %s STYLE_FILE.odt
r)ÚsysÚargvÚlenÚprintÚ__doc__ÚstderrÚexitr")Úargsrr r r!Úmain8s
r,Ú__main__)r(Ú
__future__rÚlxmlrr$r
Útempfilerrrrr"r,Ú__name__r r r r!Ú<module>
s