
    %he                        S SK r S SKrS SKJs  Jr  S SKrS SKrS SKrSS0r	S r
S rS rS
S jr\S:X  aO  \
" 5       r\" \R                   \R"                  5      r\R&                  R)                  \R+                  S	5      5        gg)    Nwz<http://schemas.openxmlformats.org/wordprocessingml/2006/mainc                     [         R                  " SS9n U R                  SSS9  U R                  SSSS9  U R                  5       n[        R
                  R                  UR                  5      (       d:  [        S	R                  UR                  5      5        [        R                  " S
5        UR                  bQ  [        R
                  R                  UR                  5      (       d#   [        R                  " UR                  5        U$ U$ ! [         a>    [        SR                  UR                  5      5        [        R                  " S
5         U$ f = f)NzGA pure python-based utility to extract text and images from docx files.)descriptiondocxzpath of the docx file)helpz-iz	--img_dirz#path of directory to extract imageszFile {} does not exist.   zUnable to create img_dir {})argparseArgumentParseradd_argument
parse_argsospathexistsr   printformatsysexitimg_dirmakedirsOSError)parserargss     I/var/www/auris/envauris/lib/python3.13/site-packages/docx2txt/docx2txt.pyprocess_argsr      s   $$ 2D EF %<=
k 1D E D77>>$))$$'..tyy9:||ww~~dll++DLL) K4K  3::4<<HIKs   * D AEEc                 \    U R                  S5      u  p[        U   nSR                  X25      $ )a  
Stands for 'qualified name', a utility function to turn a namespace
prefixed tag name into a Clark-notation qualified tag name for lxml. For
example, ``qn('p:cSld')`` returns ``'{http://schemas.../main}cSld'``.
Source: https://github.com/python-openxml/python-docx/
:z{{{}}}{})splitnsmapr   )tagprefixtagrooturis       r   qnr#   &   s-     iinOF
-CS**    c                    Sn[         R                  " U 5      nUR                  5        H  nUR                  [	        S5      :X  a  UR
                  nXb  UOS-  nM3  UR                  [	        S5      :X  a  US-  nMS  UR                  [	        S5      [	        S5      4;   a  US-  nM~  UR                  [	        S5      :X  d  M  US	-  nM     U$ )
z
A string representing the textual content of this run, with content
child elements like ``<w:tab/>`` translated to their Python
equivalent.
Adapted from: https://github.com/python-openxml/python-docx/
 zw:tzw:tab	zw:brzw:cr
zw:pz

)ET
fromstringiterr   r#   text)xmlr,   rootchildt_texts        r   xml2textr1   2   s     D==D995	!ZZF0Fb8DYY"W+%DLDYY2f:r&z22DLDYY"U)#FND  Kr$   c                 V   Sn[         R                  " U 5      nUR                  5       nSnU H=  n[        R                  " XV5      (       d  M   U[        UR                  U5      5      -  nM?     SnU[        UR                  U5      5      -  nSnU H=  n[        R                  " X5      (       d  M   U[        UR                  U5      5      -  nM?     Ub  U H  n[        R                  R                  U5      u  pU
S;   d  M,  [        R                  R                  U[        R                  R                  U5      5      n[        US5       nUR                  UR                  U5      5        S S S 5        M     UR                  5         UR                  5       $ ! , (       d  f       M  = f)Nr&   zword/header[0-9]*.xmlzword/document.xmlzword/footer[0-9]*.xml)z.jpgz.jpegz.pngz.bmpwb)zipfileZipFilenamelistrematchr1   readr   r   splitextjoinbasenameopenwriteclosestrip)r   r   r,   zipffilelistheader_xmlsfnamedoc_xmlfooter_xmls_	extension	dst_fnamedst_fs                r   processrK   H   sN   D ??4 D}}H *K88K''HTYYu-..D 
 "GHTYYw'((D *K88K''HTYYu-..D  E77++E2LA==GGLL"''2B2B52IJ	)T*eKK		% 01 +*	  	JJL::<	 +*s   !F
F(	__main__zutf-8)N)r	   r7   xml.etree.ElementTreeetreeElementTreer)   r4   r   r   r   r   r#   r1   rK   __name__r   r   r   r,   stdoutr>   encode r$   r   <module>rT      s     	 " "  	 
 
LM0	+,#L z>D499dll+DJJT[[)* r$   