+
    ¿Ìjüm  ã                   ó¤  € R t Rt^ RIt^ RIHt ^ RIHt ^ RIHtH	t	H
t
 ^ RIHt ^ RIt^ RIt ^ RIHt ]P*                  ! R4      tRtR	tR"tR#tR$tR%tR
tRtRtRt Rt!Rt"Rt#Rt$Rt%Rt&Rt'Rt(R t)R t*R t+R t, ! R R]-4      t. ! R R]/4      t0 ! R R]-4      t1R  t2]3R!8X  d   ]Ph                  ! ]2! 4       4       R# R#   ] d    ^ RIHu Ht  Lši ; i)&a·  Common operations for OpenXML files (docx, xlsx, pptx, ...)

This is mostly based on ECMA-376 (5th edition, Part 1)
http://www.ecma-international.org/publications/standards/Ecma-376.htm

See also: Notes on Microsoft's implementation of ECMA-376: [MS-0E376]

.. codeauthor:: Intra2net AG <info@intra2net>
License: BSD, see source code or documentation

ooxml is part of the python-oletools package:
http://www.decalage.info/python/oletools
z0.54.2N)Ú
log_helper)Úuopen)ÚZipFileÚ
BadZipfileÚ
is_zipfile)ÚsplitextÚooxmlz[Content_Types].xmlz_rels/.relsz#<\?mso-application progid="(.*)"\?>zWord.DocumentzExcel.SheetÚwordÚexcelÚ
powerpointÚnoneÚmixedzword-xmlz	excel-xmlzword-xml2003zexcel-xml2003c                ó  € V f   R# V P                   ^ ,          R8X  da   V P                   P                  R4      ^8X  dA   RP                  V P                   V P                   P                  R4      ^,           R 4      .pMRP                  V P                   4      .pV P                  '       d;   VP                  RP                  V P                  P                  RR	4      4      4       V P                  '       d;   VP                  R
P                  V P                  P                  RR	4      4      4       V P                  P                  4        Fû  w  r#VP                  RP                  W#4      4       VR8X  g   K.  VP                  \        4      '       d   VR;;,          R,          uu&   K`  VP                  \        4      '       d   VR;;,          R,          uu&   K’  VP                  \        4      '       d   VR;;,          R,          uu&   KÄ  V\        9   d   VR;;,          R,          uu&   Kæ  VR;;,          R,          uu&   Ký  	  RP                  V4      p\!        V4      ^–8”  d   VR,          R,           # VR,           # )z for debugging: print an element NÚNoneÚ{Ú}z[tag={{...}}{0}z[tag={0}z
text="{0}"Ú
z\nz
tail="{0}"z	{0}="{1}"ÚContentTypez-->xlsz-->docz-->pptz-->_z!!!z, :Né“   Nz...]Ú]éÿÿÿÿ)ÚtagÚcountÚformatÚindexÚtextÚappendÚreplaceÚtailÚattribÚitemsÚ
startswithÚCONTENT_TYPES_EXCELÚCONTENT_TYPES_WORDÚCONTENT_TYPES_PPTÚCONTENT_TYPES_NEUTRALÚjoinÚlen)ÚelemÚpartsÚkeyÚvaluer   s   &    Úh/home/l0st/web/w4ttz.lol/public_html/toolz/MsgDoxxer/venv/lib/python3.14/site-packages/oletools/ooxml.pyÚ	debug_strr-   €   sÉ  € à‚|ÙØ‡x�x�…{�cÔ˜dŸh™hŸn™n¨SÓ1°QÔ6Ø"×)Ñ)¨$¯(©(°4·8±8·>±>À#Ó3FÀqÕ3HÐ3IÐ*JÓKÐN‰à×"Ñ" 4§8¡8Ó,Ð/ˆØ‡y‡y€yØ�‰�]×)Ñ)¨$¯)©)×*;Ñ*;¸DÀ%Ó*HÓIÔJØ‡y‡y€yØ�‰�]×)Ñ)¨$¯)©)×*;Ñ*;¸DÀ%Ó*HÓIÔJØ—k‘k×'Ñ'Ö)‰
ˆØ�‰�\×(Ñ(¨Ó4Ô5Ø�-ÖØ×ÑÔ 3×4Ò4Ø�b—	˜YÕ&•	Ø×!Ñ!Ô"4×5Ò5Ø�b—	˜YÕ&•	Ø×!Ñ!Ô"3×4Ò4Ø�b—	˜YÕ&•	ØÔ/Ô/Ø�b—	˜WÕ$•	à�b—	˜VÕ#•	ñ *ð �:‰:�eÓ€DÜ
ˆ4ƒy�3„Ø�D�z˜GÕ#Ð#Ø�$�;Ðó    c                ó€   € \         P                  P                  ^8X  d   \        V \        4      # \        V \
        4      # )zBversion-independent test for isinstance(some_var, (str, unicode)) )ÚsysÚversion_infoÚmajorÚ
isinstanceÚ
basestringÚstr)Úsome_vars   &r,   Úisstrr7       s0   € ä
×Ñ×Ñ Ô"Ü˜(¤JÓ/Ð/Ü�h¤Ó$Ð$r.   c                óî  € \        V 4      pVP                  4       '       d—   Rp\        V R4      ;_uu_ 4       p\        P                  ! \
        VP                  R4      4      pRRR4       V'       g   \        # VP                  4       ^ ,          pV\        8X  d   \        # V\        8X  d   \        # \        # RpRpRp VP                  \        4       F�  w  r‰p\        P!                  R\#        V	4      ,           4        V	P$                  R,          p
YjP)                  \*        4      ,          pYZP)                  \,        4      ,          pYzP)                  \.        4      ,          pK’  	  T'       d   T'       g   T'       g   \4        # T'       g   T'       d   T'       g   \6        # T'       g   T'       g   T'       d   \8        # T'       g   T'       g   T'       g   \        # \        P;                  R4       \<        #   + '       g   i     EL¡; i  \&         d     EKJ  i ; i  \0         dH   pTP2                  P)                  R4      '       d!   \        TP2                  9   d   \        u Rp?# h Rp?ii ; i)	z5return one of the DOCTYPE_* constants or raise error NÚré   Fú  r   úinvalid subfilez'Encountered contradictory content types)Ú	XmlParserÚis_single_xmlr   ÚreÚsearchÚOFFICE_XML_PROGID_REGEXÚreadÚDOCTYPE_NONEÚgroupsÚWORD_XML_PROG_IDÚDOCTYPE_WORD_XMLÚEXCEL_XML_PROG_IDÚDOCTYPE_EXCEL_XMLÚiter_xmlÚFILE_CONTENT_TYPESÚloggerÚdebugr-   r   ÚKeyErrorr!   r"   r#   r$   ÚBadOOXMLÚ	more_infoÚDOCTYPE_WORDÚDOCTYPE_EXCELÚDOCTYPE_POWERPOINTÚwarningÚDOCTYPE_MIXED)ÚfilenameÚparserÚmatchÚhandleÚprog_idÚis_docÚis_xlsÚis_pptÚ_r(   Úcontent_typeÚoo_errs   &           r,   Úget_typer`   ¬   sÆ  € ä�xÓ €FØ×Ñ×ÒØˆÜ�8˜S×!Ô! VÜ—I’IÔ5°v·{±{À4Ó7HÓIˆE÷ "çÜÐØ—,‘,“. Õ#ˆØÔ&Ô&Ü#Ð#ØÔ'Ô'Ü$Ð$ÜÐà€FØ€FØ€FðØ Ÿ/™/Ô*<Ö=‰JˆA�QÜ�L‰L˜¤¨4£Õ0Ô1ðØ#Ÿ{™{¨=Õ9�ð ×-Ñ-Ô.AÓBÕBˆFØ×-Ñ-Ô.@ÓAÕAˆFØ×-Ñ-Ô.?Ó@Õ@ŠFñ >÷  —f§VÜÐß—f§VÜÐßŸ&§VÜ!Ð!ßŸ&¯ÜÐÜ
‡N�NÐ<Ô=ÜÐ÷Q "×!Ð!ûô& ô Ûðûô
 ô Ø×Ñ×&Ñ&Ð'8×9Ò9Ü" f×&6Ñ&6Ô6äÕØûðúsU   ¸+G;Â?A H" Ä HÄAH" Ç;H	ÈHÈH" ÈHÈH" È"I4È-;I/É(I4É.I/É/I4c                óv   €  \        V 4      pT\        8X  d   R# R#   \         d     R# \         d     R# i ; i)z>Determine whether given file is an ooxml file; tries get_type FT)r`   rN   ÚIOErrorrC   )rU   Údoctypes   & r,   Úis_ooxmlrd   Ü   s@   € ðÜ˜8Ó$ˆð
 ”,ÔÙÙøô ô ÚÜô Úðús   ‚ œ8ª8³8·8c                   ó¤   a € ] tR t^ît o RtRtRR ltR tR tR t	R t
R	 tRR
 lt]P                  3R ltR tR tR tR tR tR tR tRtV tR# )Ú
ZipSubFilea)  A file-like object like ZipFile.open returns them, with size and seek()

ZipFile.open() gives file handles that can be read but not seek()ed since
the file is being decompressed in the background. This class implements a
reset() function (close and re-open stream) and a seek() that uses it.
--> can be used as argument to olefile.OleFileIO and olefile.isOleFile()

Can be used as a context manager::

    with zipfile.ZipFile('file.zip') as zipper:
        # replaces with zipper.open(subfile) as handle:
        with ZipSubFile(zipper, 'subfile') as handle:
            print('subfile in file.zip has size {0}, starts with {1}'
                  .format(handle.size, handle.read(20)))
            handle.reset()

Attributes always present:
container: the containing zip file
name: name of file within zip file
mode: open-mode, 'r' per default
size: size of the stream (constructor arg or taken from ZipFile.getinfo)
closed: True if there was an open() but no close() since then

Attributes only not-None after open() and before close():
handle: direct handle to subfile stream, created by ZipFile.open()
pos: current position within stream (can deviate from actual position in
     self.handle if we fake jump to end)

See also (and maybe could some day merge with):
ppt_record_parser.IterStream; also: oleobj.FakeFile
i   Nc                ód  € Wn         W n        VfP   VP                  V4      P                  V n        \
        P                  RP                  V P                  4      4       MW@n        RVP                  4       9   d   \        RP                  V4      4      hW0n
        RV n        RV n        RV n        R# )z0remember all necessary vars but do not open yet Nzzip stream has size {0}Úwz%Can only read, mode "{0}" not allowedT)Ú	containerÚnameÚgetinfoÚ	file_sizeÚsizerK   rL   r   ÚlowerÚ
ValueErrorÚmoderX   ÚposÚclosed)Úselfri   rU   rp   rm   s   &&&&&r,   Ú__init__ÚZipSubFile.__init__  s‹   € à"ŒØŒ	ØŠ<Ø!×)Ñ)¨(Ó3×=Ñ=ˆDŒIÜ�L‰LÐ2×9Ñ9¸$¿)¹)ÓDÕEàŒIØ�$—*‘*“,ÔÜÐDß$™f T›ló,ð ,àŒ	ØˆŒØˆŒØˆŽr.   c                ó   € R # ©T© ©rs   s   &r,   ÚreadableÚZipSubFile.readable!  ó   € Ùr.   c                ó   € R # )Frx   ry   s   &r,   ÚwritableÚZipSubFile.writable$  s   € Ùr.   c                ó   € R # rw   rx   ry   s   &r,   ÚseekableÚZipSubFile.seekable'  r|   r.   c                ó¾   € V P                   e   \        R4      hV P                  P                  V P                  V P
                  4      V n         ^ V n        RV n        V # )z@open subfile for reading; open mode given to constructor before zre-opening file not supported!F)rX   rb   ri   Úopenrj   rp   rq   rr   ry   s   &r,   r„   ÚZipSubFile.open*  sK   € à�;‰;Ò"ÜÐ:Ó;Ð;Ø—n‘n×)Ñ)¨$¯)©)°T·Y±YÓ?ˆŒØˆŒØˆŒàˆr.   c                ó   € \        R4      h)zwrite is not allowed zwriting not implemented)rb   ©rs   ÚargsÚkwargss   &*,r,   ÚwriteÚZipSubFile.write4  s   € äÐ/Ó0Ð0r.   c                óì   € V P                   f   \        R4      hV P                  V P                  8¼  d   R# V P                   P	                  V4      pV ;P                  \        V4      ,          un        V# )zm
read given number of bytes (or all data) from stream

returns bytes (i.e. str in python2, bytes in python3)
zread on closed handler.   )rX   rb   rq   rm   rB   r'   )rs   rm   Údatas   && r,   rB   ÚZipSubFile.read8  sX   € ð �;‰;ÒÜÐ1Ó2Ð2Ø�8‰8�t—y‘yÔ áØ�{‰{×Ñ Ó%ˆØ�Š”C˜“IÕ�àˆr.   c                ó`  € V\         P                  8X  d   TpMlV\         P                  8X  d   V P                  V,           pMCV\         P                  8X  d   V P
                  V,           pM\        RP                  V4      4      hV^ 8  d   \        R4      hW0P                  8X  d   R# V^ 8X  d   V P                  4        R# W0P                  8  d$   V P                  4        V P                  V4       R# W0P
                  8  d$   V P                  W0P                  ,
          4       R# W0n        R# )z4re-position point so read() will continue elsewhere z(invalid offset {0}, need SEEK_* constantz%Seek beyond start of file not allowedN)ÚioÚSEEK_SETÚSEEK_CURrq   ÚSEEK_ENDrm   ro   r   rb   ÚresetÚ
_seek_skip)rs   rq   ÚoffsetÚnew_poss   &&& r,   ÚseekÚZipSubFile.seekH  sÕ   € ð ”R—[‘[Ô Ø‰GØ”r—{‘{Ô"Ø—h‘h •n‰GØ”r—{‘{Ô"Ø—i‘i #•o‰GäÐGß$™f V›nó.ð .ð �QŒ;äÐAÓBÐBØŸ™Ô áØ˜Œ\à�J‰JŽLØ—x‘xÔà�J‰JŒLØ�O‰O˜GÖ$Ø—y‘yÔ à�O‰O˜G§h¡hÕ.Ö/ð ŽHr.   c                ó°   € \        WP                  4      w  r#\        V4       F  pV P                  V P                  4       K   	  V P                  V4       R# )z;helper for seek: skip forward by given amount using read() N)ÚdivmodÚ
CHUNK_SIZEÚrangerB   )rs   Úto_skipÚn_chunksÚleftoverr]   s   &&   r,   r•   ÚZipSubFile._seek_skipj  s?   € ô $ G¯_©_Ó=ÑˆÜ�x–ˆAØ�I‰I�d—o‘oÖ&ñ !à�	‰	�(Ör.   c                ó   € V P                   # )z#inform about position of next read )rq   ry   s   &r,   ÚtellÚZipSubFile.tellu  s   € ð �x‰xˆr.   c                óF   € V P                  4        V P                  4        R# )zclose and re-open N)Úcloser„   ry   s   &r,   r”   ÚZipSubFile.resetz  s   € ð 	�
‰
ŒØ�	‰	Žr.   c                ó€   € V P                   e   V P                   P                  4        RV n        RV n         RV n        R# )zclose file NT)rX   r¦   rq   rr   ry   s   &r,   r¦   ÚZipSubFile.close€  s3   € ð �;‰;Ò"Ø�K‰K×ÑÔØˆŒØˆŒØˆŽr.   c                ó&   € V P                  4        V # )z)start of context manager; opens the file )r„   ry   s   &r,   Ú	__enter__ÚZipSubFile.__enter__‰  s   € ð 	�	‰	ŒØˆr.   c                ó&   € V P                  4        R# )z(end of context manager; closes the file N)r¦   r‡   s   &*,r,   Ú__exit__ÚZipSubFile.__exit__�  s   € ð 	�
‰
Žr.   c                ó"  € V P                   f   RpMMV P                  ^ 8X  d   RpM9V P                  V P                  8¼  d   RpMRP                  V P                  4      pRP                  V P                  V P                  V P
                  V4      # )z6creates a nice textual representation for this object rr   zopen, at startzopen, at endzopen, at pos {0}z*[ZipSubFile {0} (size {1}, mode {2}, {3})])rX   rq   rm   r   rj   rp   )rs   Ústatuss   & r,   Ú__str__ÚZipSubFile.__str__”  so   € à�;‰;ÒØ‰FØ�X‰X˜Œ]Ø%‰FØ�X‰X˜Ÿ™Ô"Ø#‰Fà'×.Ñ.¨t¯x©xÓ8ˆFà;ß‘�t—y‘y $§)¡)¨T¯Y©Y¸Ó?ð	@r.   )rr   ri   rX   rp   rj   rq   rm   )r9   N)r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rœ   rt   rz   r~   r�   r„   rŠ   rB   r�   r‘   r˜   r•   r£   r”   r¦   r«   r®   r²   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r,   rf   rf   î   sm   ø‡ € ñð> €Jôò"òòòò1ôð   "Ÿ{™{ô  òDòò
òòò÷
@ð @r.   rf   c                   ó:   a a€ ] tR tRt oRtRV 3R lltRtVtV ;t# )rN   i£  z3exception thrown if file is not an office XML file c                ó†   <€ \         \        T `  RP                  Y'       d
   RV,           MR4      4       Wn        W n        R# )z2create exception, remember filename and more_info z {0} is not an Office XML file{1}z: Ú N)ÚsuperrN   rt   r   rU   rO   )rs   rU   rO   Ú	__class__s   &&&€r,   rt   ÚBadOOXML.__init__¦  s7   ø€ äŒh˜Ñ&Ø.ß‰V�H¶)˜d YÖ.ÀÓDô	Fð !ŒØ"Žr.   )rU   rO   ©N)	r´   rµ   r¶   r·   r¸   rt   r¹   rº   Ú__classcell__)rÁ   r¼   s   @@r,   rN   rN   £  s   ù‡ € Ù>÷#÷ #r.   rN   c                   óP   a € ] tR tRt o RtR tR tRR ltRR ltR t	R	 t
R
tV tR# )r=   i´  ar  parser for OOXML files

handles two different types of files: "regular" OOXML files are zip
archives that contain xml data and possibly other files in binary format.
In Office 2003, Microsoft introduced another xml-based format, which uses
a single xml file as data source. The content of these types is also
different. Method :py:meth:`is_single_xml` tells them apart.
c                óL   € Wn         R V n        \        4       V n        RV n        R# )FN)rU   Údid_iter_allÚsetÚsubfiles_no_xmlÚ_is_single_xml)rs   rU   s   &&r,   rt   ÚXmlParser.__init__¾  s!   € Ø ŒØ!ˆÔÜ"›uˆÔØ"ˆÖr.   c                ó˜  € V P                   e   V P                   # \        V P                  4      '       d
   RV n         R# Rp\        V P                  R4      ;_uu_ 4       p\        P
                  ! \        VP                  R4      4      pRRR4       V'       d
   RV n         R# \        V P                  R4      h  + '       g   i     L7; i)zvdetermine whether this is "regular" ooxml or a single xml file

Raises a BadOOXML if this is neither one or the other
NFr9   r:   Tzis no zip and has no prog_id)	rÊ   r   rU   r   r?   r@   rA   rB   rN   )rs   rW   rX   s   &  r,   r>   ÚXmlParser.is_single_xmlÄ  s˜   € ð
 ×ÑÒ*Ø×&Ñ&Ð&ä�d—m‘m×$Ò$Ø"'ˆDÔÙð ˆÜ�4—=‘= #×&Ô&¨&Ü—I’IÔ5°v·{±{À4Ó7HÓIˆE÷ 'çØ"&ˆDÔÙÜ�t—}‘}Ð&DÓEÐE÷ '×&ús   Á+B9Â9C		Nc              #  óº  "  € V P                  4       '       dU   V'       d   \        V P                  R4      h\        V P                  R4      ;_uu_ 4       pRV3x € RRR4       RV n        R# RpRp \        V P                  4      pV'       g   VP                  4       pMA\        V4      '       d   V.pM,\        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      pV F+  pVP                  VR4      ;_uu_ 4       pWR3x € RRR4       K-  	  V'       g   RV n        T'       d   TP                  4        R# R#   + '       g   i     Lé; i  + '       g   i     K~  ; i  \         d,   p\        T P                  R\        T4      ,           4      hRp?i\         d    \        T P                  R4      hi ; i  T'       d   TP                  4        i i ; i5i)	zù
Find files in zip or just give single xml file

yields pairs (subfile-name, file-handle) where file-handle is an open
file-like object. (Do not care too much about encoding here, the xml
parser reads the encoding from the first lines in the file.)
zxml has no subfilesÚrbNTc              3   ó$   "  € T F  qx € K  	  R # 5irÃ   rx   )Ú.0Úargs   & r,   Ú	<genexpr>Ú'XmlParser.iter_files.<locals>.<genexpr>ô  s   é € Ð$9±D¨S¤S³Dùs   ‚r9   zinvalid subfile: znot in zip format)r>   rN   rU   r„   rÇ   r   Únamelistr7   ÚtuplerM   r5   r   r¦   )rs   rˆ   rX   ÚzipperÚsubfilesÚsubfileÚorig_errs   &&     r,   Ú
iter_filesÚXmlParser.iter_filesÙ  sw  é € ð ×Ñ×ÒßÜ˜tŸ}™}Ð.CÓDÐDä�d—m‘m T×*Ô*¨fØ˜F�lÒ"÷ +à $ˆDÖàˆFØˆHð#Ü  §¡Ó/�ßØ%Ÿ™Ó0‘HÜ˜4—[’[Ø $˜x‘H÷  %œuÑ$9±DÓ$9Ÿu™uÑ$9±DÓ$9Ó9�Hã'�GØŸ™ W¨c×2Ô2°fØ%˜oÒ-÷ 3Ñ2ñ  (÷ Ø(,�DÔ%÷ Ø—L‘L–Nñ ÷= +×*ú÷$ 3×2Ð2ûô ô Dô ˜tŸ}™}Ø2´S¸³]ÕBóDð Dûäô CÜ˜tŸ}™}Ð.AÓBÐBðCû÷ Ø—L‘L•Nð üs~   ‚G¡4GÁD=ÁGÁ2AE$ Ã A E$ Ä EÄE$ ÄE$ Ä!GÄ=E	ÅGÅE!Å	E$ Å$F:Å/&FÆF:Æ"F:Æ:F= Æ=GÇGc           	   #  óH  "  € Vf   . pM_\        V4      '       d)   V.p\        P                  RP                  V4      4       M&Tp\        P                  RP                  V4      4       V P	                  V4       EFÎ  w  rVRp^ p. p	 \
        P                  ! Wg4       EF�  w  r«Vf   K  V
R8X  di   VP                  V9   dM   \        P                  RP                  VP                  V4      4       V	P                  VP                  V34       V^,          pK{  V
R8X  g   Q hV^,          pV^ 8¼  g   Q hVP                  V9   pV'       dµ   VP                  V3p V	R,          V8X  d   V	P                  4        M†\        P                  RP                  VV	R,          4      4       V	'       dS   V	R,          ^,          V8¼  d>   \        P                  RP                  V	R,          4      4       V	P                  4        KZ  V'       g	   V'       g   W[V3x € V'       d   EK‚  V	'       d   EK�  VP                  4        EK   	  T^ 8X  d   EKÏ  Q h	  R#   \         d    \        P                  R4        Lsi ; i  \
        P                   d–   pT P                  P                  T4       Tf   \!        T P"                  R	4      hTP%                  R
4      '       d   \        P&                  pM\        P                  pT! RP                  Y^4      R,           4        Rp?LÛRp?ii ; i5i)aà  Iterate xml contents of document

If given subfile name[s] as optional arg[s], will only parse that
subfile[s]

yields 3-tuples (subfilename, element, depth) where depth indicates how
deep in the hierarchy the element is located. Containers of element
will come *after* the elements they contain (since they are only
finished then).

Subfiles that are not xml (e.g. OLE or image files) are remembered
internally and can be retrieved using iter_non_xml().

The argument need_children is set to False per default. If you need to
access an element's children, set it to True. Note, however, that
leaving it at False should save a lot of memory. Otherwise, the parser
has to keep every single element in memory since the last element
returned is the root which has the rest of the document as children.
c.f. http://www.ibm.com/developerworks/xml/library/x-hiperfparse/

Argument tags restricts output to tags with names from that list (or
equal to that string). Children are preserved for these.
Nzlooking for tags: {0}ÚstartÚendz remember start of tag {0} at {1}zBfound end for wanted tag {0} but last start tag {1} does not matchzrecover: pop {0}z0found end of {0} at depth {1} but no start eventzcontent is not valid XMLz.xmlz$  xml-parsing for {0} failed ({1}). z Run iter_non_xml to investigate.)rÞ   rß   r   )r7   rK   rL   r   rÛ   ÚETÚ	iterparser   r   ÚpopÚerrorÚ
IndexErrorÚclearÚ
ParseErrorrÉ   ÚaddrN   rU   ÚendswithrS   )rs   rØ   Úneed_childrenÚtagsÚ	want_tagsrÙ   rX   ÚeventsÚdepthÚinside_tagsÚeventr(   Ú	is_wantedÚcurr_tagÚerrÚlogs   &&&&            r,   rI   ÚXmlParser.iter_xml  s‘  é € ð0 Š<Ø‰IÜ�4�[Š[Ø˜ˆIÜ�L‰LÐ0×7Ñ7¸Ó=Õ>àˆIÜ�L‰LÐ0×7Ñ7¸Ó=Ô>à#Ÿ™¨x×8‰OˆGØ%ˆFØˆEØˆKð78Ü#%§<¢<°×#?‘K�EØ’|Ù Ø Ô'ØŸ8™8 yÔ0Ü"ŸL™LÐ)Kß*0©&°·±¸5Ó*AôCà'×.Ñ.°·±¸%Ð/@ÔAØ �
˜Ù Ø  Eœ>Ð*˜>Ø˜Q•J�EØ  Aœ:Ð&˜:à $§¡¨IÑ 5�Iß Ø$(§H¡H¨eÐ#4˜ð;Ø*¨2�°(Ô:Ø +§¡Õ 1ä &§¡ð .6ç6<±f¸XØ=HÈ½_ó7Nô!O÷
 '2Ø(3°B­¸Õ(:¸eÔ(CÜ$*§L¡LÐ1Cß28±&¸ÀR½Ó2Iô%Kà$/§O¡OÖ$5÷
 !¯	Ø%¨UÐ2Ò2÷ )š=·²ØŸ
™
ŸñQ $@ðn ˜A—:Ð�:óy  9øôH  *ô ;Ü"ŸL™Lð *:ö ;ð;ûô —=‘=ô 
8Ø×$Ñ$×(Ñ(¨Ô1Ø’?Ü" 4§=¡=Ð2LÓMÐMØ×%Ñ% f×-Ò-Ü Ÿ.™.‘Cä Ÿ,™,�CÙÐ:ß‘V˜GÓ)Ø6õ7÷ 8ñ 8ûð
8üs“   ‚BL"ÂCI5Å
I5ÅIÅ7I5Å83IÆ,AIÇ>I5ÈI5ÈI5ÈI5È*I5È?L"É	L"É I2É/I5É1I2É2I5É5LÊ
ALË?LÌL"ÌLÌL"c                óÜ  € V P                  4       '       d   / / 3# . p. p V P                  \        4       EFO  w  r4pVP                  P	                  R4      '       d„   VP
                  R,          pVP                  R4      '       d
   VR,          pVP                  WTP
                  R,          34       \        P                  RP                  VR,          4      4       K«  VP                  P	                  R4      '       g   KÎ  VP
                  R,          pVP                  R	4      '       d
   VR,          pVP                  WdP
                  R,          34       \        P                  R
P                  VR,          4      4       EKR  	  \        T4      \        T4      3#   \         dB   pTP                  P                  R4      '       d   \        TP                  9   d    Rp?L\h Rp?ii ; i)zýretrieve subfile infos from [Content_Types].xml subfile

returns (files, defaults) where
- files is a dict that maps file-name --> content-type
- defaults is a dict that maps extension --> content-type

No guarantees on accuracy of these content types!
ÚDefaultÚ	ExtensionÚ.ºé   NNr   z/found content type for extension {0[0]}: {0[1]}ÚOverrideÚPartNameÚ/z-found content type for subfile {0[0]}: {0[1]}r<   Nr   )r>   rI   rJ   r   rè   r   r!   r   rK   rL   r   rN   rO   Údict)rs   ÚdefaultsÚfilesr]   r(   Ú	extensionrÙ   r_   s   &       r,   Úget_content_typesÚXmlParser.get_content_typese  s‚  € ð ×Ñ×ÒØ�r�6ˆMàˆØˆð	Ø"Ÿm™mÔ,>×?‘
�˜Ø—8‘8×$Ñ$ Y×/Ò/Ø $§¡¨KÕ 8�IØ ×+Ñ+¨C×0Ò0Ø$-¨b¥M˜	Ø—O‘O Y·±¸MÕ0JÐ$KÔLÜ—L‘Lð "*ß*0©&°¸"µÓ*>ö@à—X‘X×&Ñ& z×2Ô2Ø"Ÿk™k¨*Õ5�GØ×)Ñ)¨#×.Ò.Ø")¨"¥+˜Ø—L‘L '¯;©;°}Õ+EÐ!FÔGÜ—L‘Lð "*ß*0©&°°rµÓ*;÷=ñ @ô. �E‹{œD ›NÐ*Ð*øô ô 	Ø×Ñ×*Ñ*Ð+<×=Ò=Ü&¨&×*:Ñ*:Ô:ô àûð	ús2    A&F ÂA7F Ä)F Ä-AF ÆG+Æ*6G&Ç%G&Ç&G+c           
   #  óÀ  "  € V P                   '       g   \        P                  R4       V P                  '       g   R# V P	                  4       '       d   R# V P                  4       w  r\        V P                  4      ;_uu_ 4       pV P                   F–  pVP                  R4      '       d
   VR,          pRpWA9   d
   W,          pM@\        V4      ^,          pVP                  R4      '       d
   VR,          pWb9   d	   W&,          p\        W44      ;_uu_ 4       pWEV3x € RRR4       K˜  	  RRR4       R#   + '       g   i     Kµ  ; i  + '       g   i     R# ; i5i)aÊ  retrieve subfiles that were found by iter_xml to be non-xml

also looks for content type info in the [Content_Types].xml subfile.

yields 3-tuples (filename, content_type, file_handle) where
content_type is based on filename or default for extension or is None,
and file_handle is a ZipSubFile. Caller does not have to care about
closing handle, will be closed even in error condition.

To handle binary parts of an xlsb file, use xls_parser.parse_xlsb_part
zQDid not iterate through complete file. Should run iter_xml() without args, first.Nrý   rù   rø   )rÇ   rK   rS   rÉ   r>   r  r   rU   r!   r   rf   )rs   Úcontent_typesÚcontent_defaultsr×   rÙ   r^   r  rX   s   &       r,   Úiter_non_xmlÚXmlParser.iter_non_xml�  s  é € ð × × Ð Ü�N‰Nð Hô Ià×#×#Ð#Ùð ×Ñ×ÒÙà*.×*@Ñ*@Ó*BÑ'ˆä�T—]‘]×#Ô# vØ×/Ô/�Ø×%Ñ% c×*Ò*Ø% b�k�GØ#�ØÔ+Ø#0Õ#9‘Lä (¨Ó 1°!Õ 4�IØ ×+Ñ+¨C×0Ò0Ø$-¨b¥M˜	Ø Ô4Ø'7Õ'B˜Ü ×0Ô0°FØ!°Ð7Ò7÷ 1Ñ0ñ 0÷ $Ñ#÷ 1×0Ð0ú÷ $×#Ð#üsA   ‚9E¼EÁ1EÂBE
ÄD6Ä E
Ä,
EÄ6EÅ	E
Å
E	Å	E)rÊ   rÇ   rU   rÉ   rÃ   )NFN)r´   rµ   r¶   r·   r¸   rt   r>   rÛ   rI   r  r  r¹   rº   r»   s   @r,   r=   r=   ´  s2   ø‡ € ñò#òFô*+#ôZ]ò~&+÷P&8ð &8r.   r=   c            
     ó®  € \         P                  ! RR4       \        \        P                  4      ^8w  d   \        R4       ^# \        R\        \        P                  ^,          4      ,           4       \        \        P                  ^,          4      p V P                  4        F;  w  rpV^8  g   K  \        RP                  VRV,          \        V4      4      4       K=  	  \        V P                  4       4       FA  w  pw  rp\        RP                  Y;'       g    R4      4       V^d8”  g   K6  \        R	4        M	  \         P                  ! 4        ^ # )
z‹
Test xml parsing; called when running this file as a script.

Prints every element found in input file (to be given as command line arg).
FrL   z/To test this code, give me a single file as argzDetected type: z
{0} {1}{2}r;   z Non-XML subfile: {0} of type {1}Úunknownz...)r   Úenable_loggingr'   r0   ÚargvÚprintr`   r=   rI   r   r-   Ú	enumerater  Úend_logging)rV   rÙ   r(   rí   r   r^   r]   s          r,   Útestr  ¶  s  € ô ×Ò˜e WÔ-Ü
Œ3�8‰8ƒ}˜ÔÜÐ@ÔAÙô 
Ð
œh¤s§x¡x°¥{Ó3Õ
3Ô4ô ”s—x‘x •{Ó#€FØ &§¡Ö 1Ñˆ�uØ�1Ž9Ü�-×&Ñ& w°°uµ¼iÈ»oÓNÖOñ !2ô .7°v×7JÑ7JÓ7LÖ-MÑ)ˆÑ)� qÜÐ1ß‰v�g×9Ð9¨zÓ:ô	<à�3Ž;Ü�&ŒMÙñ .Nô ×ÒÔár.   Ú__main__)z<application/vnd.openxmlformats-officedocument.spreadsheetml.zapplication/vnd.ms-excel.)z?application/vnd.openxmlformats-officedocument.wordprocessingml.)z=application/vnd.openxmlformats-officedocument.presentationml.)zapplication/xmlz8application/vnd.openxmlformats-package.relationships+xmlz:application/vnd.openxmlformats-package.core-properties+xmlz7application/vnd.openxmlformats-officedocument.theme+xmlzEapplication/vnd.openxmlformats-officedocument.extended-properties+xml)5r¸   Ú__version__r0   Úoletools.common.log_helperr   Úoletools.common.io_encodingr   Úzipfiler   r   r   Úos.pathr   r�   r?   Ú
lxml.etreeÚetreerà   ÚImportErrorÚxml.etree.cElementTreeÚcElementTreeÚget_or_create_silent_loggerrK   rJ   ÚFILE_RELATIONSHIPSr"   r#   r$   r%   rA   rE   rG   rP   rQ   rR   rC   rT   rF   rH   ÚDOCTYPE_WORD_XML2003ÚDOCTYPE_EXCEL_XML2003r-   r7   r`   rd   Úobjectrf   ro   rN   r=   r  r´   Úexitrx   r.   r,   Ú<module>r"     s9  ðñðX €ó Ý 1Ý -ß 3Ñ 3Ý Û 	Û 	ð(åð 
×	/Ò	/°Ó	8€ð +Ð Ø"Ð ðÐ ðÐ ðÐ ð
Ð ð AÐ Ø"Ð Ø!Ð ð €Ø€Ø!Ð Ø€Ø€ØÐ ØÐ Ø%Ð Ø'Ð òò@%ò-ò`
ô$r@�ô r@ôj	#ˆzô 	#ô"8�ô 8òDð> ˆzÔØ‡H‚H‰T‹VÖñ øð] ô (ß'Ò'ð(ús   ®B< Â<CÃC